How to find and replace multiple values at once in Excel?
As we all known, we can use Find and Replace function to find multiple same cell and replace them with a value as you need. But sometimes, you need to apply many-to-many replacement simultaneously. For example, I have a range of data, and now I want to replace all Apples to Red Apples, Oranges to Green Oranges, Bananas to Yellow Bananas and so on as following screenshots shown, do you have any good ideas to solve this task in Excel?
Find and replace multiple values at once with VBA code
If you are tired of find and replace the values time and time again, the following VBA code can help you to replace multiple values with your needed texts at once.
1. Please create your conditions that you want to use which contain the original values and new values. See screenshot:
2. Then hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module window.
VBA code: Find and replace multiple values at once
Sub MultiFindNReplace() 'Updateby Extendoffice Dim Rng As Range Dim InputRng As Range, ReplaceRng As Range xTitleId = "KutoolsforExcel" Set InputRng = Application.Selection Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8) Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8) Application.ScreenUpdating = False For Each Rng In ReplaceRng.Columns(1).Cells InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value Next Application.ScreenUpdating = True End Sub
4. Then press F5 key to run this code, in the popped out prompt box, please specify the data range that you want to be replaced the values with new values.
5. Click OK, and another prompt box is displayed to remind you select the criteria which you are created in step 1. See screenshot:
6. Then click OK, all the specific values have been replaced with the new values as you need immediately.
Related articles:
How to find and replace specific text in text boxes?
How to find and replace text in chart titles in Excel?
How to find and replace text within comments in Excel?
How to change multiple hyperlink paths at once in Excel?
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
- Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
- Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
- Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
- Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
- Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
- Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
- Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
- Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
- More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

You are guest
or post as a guest, but your post won't be published automatically.
-
To post as a guest, your comment is unpublished.· 4 months agoThis is pretty cool. Is there a way that we could change it to work across the whole Workbook instead of a specific range?
-
To post as a guest, your comment is unpublished.Running into an issue when an Original Value is a subset of another, is there a way to look for Exact Match or another workaround? See attached image for example, result cell highlighted red is the issue. In case the image doesn't work, here's a typed out modified version:Original Value1: Call Option Risk | Replacing Value1: ^b^Call Option Risk^/b^
Original Value2: Index Call Option Risk | Replacing Value2: ^b^Index Call Option Risk^/b^[as you can see, OV2 contains OV1 but is not an exact match]Result of MultiFindNReplace() on OV2: Index ^b^Call Option Risk^/b^ [but I'm expecting ^b^Index Call Option Risk^/b^]Thanks-
To post as a guest, your comment is unpublished.Hello, sameer,
May be the following code can solve your problem, please try it:
Sub MultiFindNReplace()
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, LookAt:=xlWhole, MatchCase:=True
Next
Application.ScreenUpdating = True
End Sub
Hope it can help you!
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.skyyang - Thanks. This version does not work in my case since it appears to 'match entire cell contents' but I need to replace only part of the string. I realize now that the example I typed out does not communicate this detail; can you see the JPG I attached instead? Original Range:
Product1 = Call Option: risk 1
Product2 = Index Call Option: risk 2
It's the extra text after the colon that breaks your version. And OP's code is able to ignore the extra text, but can't differentiate between "Call Option Risk:" and "Index Call Option Risk:". Again, I think the picture explains this best, if you could please take another look.
-
-
-
To post as a guest, your comment is unpublished.How skip cell after first match?
I've sorted translations from longest phrase to shortest.-
To post as a guest, your comment is unpublished.Hi, ksec,
Could you give more detailed information about your problem? Or you can insert a screenshot here to show your problem.
Thank you!-
To post as a guest, your comment is unpublished.He means that if a part of the original repeats later there is an issue because the function replace again, sorted or not, if the original word is not unique (even a part of it) this function does not work
-
To post as a guest, your comment is unpublished.Hello, mar_m,
Please apply the below code, try if it can solve your problem, Thank you!
Sub MultiFindNReplace()
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, LookAt:=xlWhole, MatchCase:=True
Next
Application.ScreenUpdating = True
End Sub
-
-
-
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi!
i need this macro to work on specific columns without selecting different columns each time manually.
is there any way to mention desired columns and replacing table in the code?
appreciated -
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Thanks a lot, that works perfectly !
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi im TG,Thank you for posting this page, It's very useful and make it very simple of my work and save more time , thank you sir....
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi, I would like to replace whole cells in the entire Excel file (with many sheets). What should be replace in the Original Range to do that? Thanks.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Can I ask if I want to replace the entire cell based on partial match, how should I alter the code?
For example: I want to code all cells containing the word apple to 1 (regardless whether it's "green apple" or "red apple"), I want all of them to turn into 1. -
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.The VBA method of find and replace is not working. It was working for me till yesterday but today I am not able to do any find and replace using it today. Can you guys please help
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi
I have to replace list of bank with proper name based on key words. For example, if somebody enters Halifax, it should be Halifax Bank of Scotland (HBOS) or if somebody enters LloydsTSB, it should be Lloyds.
Original value Replacing Value
LloydsTSB : Lloyds
Santander : Santander (Abbey)
Argos Card Services : Argos
Halifax : Halifax Bank of Scotland (HBOS)
The down formula works in many cases. But if there is two Halifax bank on my list, I will get Halifax Bank of Scotland (HBOS) (HBOS)
. So, first time it finds Halifax, replace with correct one. Again it finds Halifax and replace. How can I correct this problem ?
Sub FindReplaceNew()
Dim xTitledId As String
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitledId = "Test"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range", xTitledId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitledId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
Next
Application.ScreenUpdating = False
End Sub -
To post as a guest, your comment is unpublished.I modified this to work on Microsoft Excel for Mac 2016 and to replace strings that are within whole words. Here are the first and last lines I changed (along with the stuff in between that I didn't change).
Set InputRng = Application.InputBox(Prompt:="Original Range :", Title:="Range to search", Default:=InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox(Prompt:="Replace Range :", Title:="Replace mapping range", Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, LookAt:=xlPart -
To post as a guest, your comment is unpublished.Hello, how can I only replace full words (and not strings within a word) ? By word, I mean a string that is at the beginning/end of the cell or preceded/followed with a space.
-
To post as a guest, your comment is unpublished.Use this code.
Sub MultiFindNReplace()
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "MultipleReplaceValue"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, LookAt:=xlWhole, MatchCase:=True
Next
Application.ScreenUpdating = True
End Sub-
To post as a guest, your comment is unpublished.Thanks a Ton man.It worked just fine.
-
-
To post as a guest, your comment is unpublished.
-
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Sub MultiFindNReplace()
'Update 20140722
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range
", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range
:", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
' InputRng.Replace what:=Rng.Value,
replacement:=Rng.Offset(0, 1).Value
InputRng.Replace
Rng.Value, Rng.Offset(0, 1).Value
Next
MsgBox "Done Successfully....", vbInformation
Application.ScreenUpdating = True
End Sub -
To post as a guest, your comment is unpublished.THANKS A LOT.....
ITS MOST EFFECTIVE CODE TO USE....
THANKS SIR, -
To post as a guest, your comment is unpublished.how do I implement "match entire cell content" in this code?
-
To post as a guest, your comment is unpublished.in case someone else is looking for this, here it is:
Replace this line
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
by
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, LookAt:=xlWhole
It will look for the whole cell in target and original, and replace by a whole cell instead of particular instances of doubles inside a cell
-
-
To post as a guest, your comment is unpublished.don't work in all the columns for me idk why
-
To post as a guest, your comment is unpublished.Perfect Solution.
Easy to use. -
To post as a guest, your comment is unpublished.Hi, this was very powerful and useful code. Thanks a lot! There is just a couple of features lacking and it would be perfect for me: 1) Could it be possible to modify the code so that it would process multiple files at once? For example you have your find_replace attributes in different file and then you just name the files in the VBA code you want to modify. I dunno...That would be cool. 2) Could it be possible to make a report so that I would know what attributes were replaced. So that I could double-check if something went wrong.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.How can I make this VBA macro work for a formula, e.g. if I want to replace 'Sheet1!$A:$A' with Table1[A]?
-
To post as a guest, your comment is unpublished.This is AWESOME!!! Very simple solution to my problem. THANK YOU!
-
To post as a guest, your comment is unpublished.in case anybody still struggles with replacing entire cell value and not just part: use Lookat:=xlWhole
Sub MultiFindNReplace()
'Update 20140722
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value , replacement:=Rn g.Offset(0, 1).Value, Lookat:=xlWhole
Next
Application.ScreenUpdating = True
End Sub -
To post as a guest, your comment is unpublished.thanks, you're great. Your script saved me at least half an hour of find and replace :lol:
-
To post as a guest, your comment is unpublished.This tutorial was excellent! Did what I needed it to do.
Is there a way to automatically run this macro on specific columns every time I open it/after pressing a key or something easy? After I've already saved the macro on a macro enabled file. I am creating a document to share with my colleagues and I'm not sure everyone will follow all the steps.
Thank you! -
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.This saved me hours of work. Thank you soooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo much.
-
To post as a guest, your comment is unpublished.I LOVE this formula and use it all the time!
I need a very similar formula but can't work out the logic.
Column A is full cells with lots of text.
Column B is full of my 'keywords' that I want to extract, much like the 'Original Value' in this formula.
Column C needs to be the words from Column A that match the 'keywords' in Column B. Ideally they would be separated by commas with NO spaces, but I can use tools to insert these.
Thanks, guys, your stuff is amazing! -
To post as a guest, your comment is unpublished.How to do it for Exact Cell match?? if not exact, it should leave it.
-
To post as a guest, your comment is unpublished.Hie guys, I have used the Macro Below and it worked perfectly, however I am now having challenges with filtered values, is it possible to make the effect of the macro only on the filtered data.
Sub MultiFindNReplace()
'Update 20140722
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
Next
Application.ScreenUpdating = True
End Sub
Please help urgently, my boss is on my neck. -
To post as a guest, your comment is unpublished.So I'm trying to do a replacement range as seen below.
Original Value Replacing range.
0 to 1 1
0 to 2 1,2
0 to 99 1,2,3,4,5,6,7,8,9,10,11,12,13
13 to 99 13
However anything with 99 in it gives me a funky number and doesn't replace properly. I don't know what to do. Something broke as of recently Because this script was working fine last week. Now it's all broken. I'm getting replacement like 14,5,6,7,8,9,109, for the value 13 to 99. And for the value 8 to 99 it's replacing it with 19109. I'm at a complete loss here. Help! -
To post as a guest, your comment is unpublished.So I'm trying to use this script to a replacement with age ranges. To a code listing. But it's not inputting correctly.
Original Value Replacing Value
0 to 1 1
0 to 2 1,2
0 to 3 1,2,3
0 to 4 1,2,3,4
0 to 5 1,2,3,4,5
0 to 6 1,2,3,4,5,6
0 to 7 1,2,3,4,5,6,7
0 to 8 1,2,3,4,5,6,7,8
0 to 9 1,2,3,4,5,6,7,8,9
0 to 10 1,2,3,4,5,6,7,8,9,10
0 to 11 1,2,3,4,5,6,7,8,9,10,11
0 to 12 1,2,3,4,5,6,7,8,9,10,11,12
0 to 13 1,2,3,4,5,6,7,8,9,10,11,12,13
13 to 99 13
As you see above this is how the replacing ranges should look. But for numbers like 13 to 99 it gets replaced with like 14,15,16,109 instead of of having the replacement be 13. I don't know what is causing this. Last week this script was working fine but now it broke. -
To post as a guest, your comment is unpublished.Hi:
I need to replace a formula (=F108+Start!I108) with (=F108+'Jan 17'!I108) throughout the sheet. I am not able to just find and replace since there is only one cell with that formula. Each cell has its own number... Can you help to to find the replace the Start with Jan 17. Thank you. -
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.how to change 32642/319/09-07-08 only change 32642-319/09-07-08 this format all sheet only change first / to - not change all