Multiple Find and Replace

Michel Montreal

New Member
Joined
Feb 18, 2016
Messages
1
Hello,
I was successfully using this Multiple Find & Replace code (which is on several websites) for the last 2 years at my job and now it's been a few weeks it doesn't work anymore.
I spent several hours researching a solution and trying a few tweaks but my knowledge in VBA is very little and I just don't get to get this code to work (nothing happens when I run the code, no error message). Can anyone please help me?

Basically, I have a column with company names (original range), where I need to find certain names and replace them there. [TABLE="width: 500"]
<tbody>[TR]
[TD]Name (original range)[/TD]
[TD][/TD]
[TD]Find[/TD]
[TD]Replace for[/TD]
[/TR]
[TR]
[TD]Sofa[/TD]
[TD][/TD]
[TD]Desk[/TD]
[TD]Desktop[/TD]
[/TR]
[TR]
[TD]Table[/TD]
[TD][/TD]
[TD]Car[/TD]
[TD]Truck[/TD]
[/TR]
[TR]
[TD]Desk[/TD]
[TD][/TD]
[TD]Sofa[/TD]
[TD]Couch[/TD]
[/TR]
[TR]
[TD]Car[/TD]
[TD][/TD]
[TD]Table[/TD]
[TD]Tablecloth[/TD]
[/TR]
</tbody>[/TABLE]

This is the code:
Code:
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

Thanks a lot!!!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I tried your code, and it worked!
Are you sure you select the right range for both inputbox?
Here's the result:

ABCD
Name (original range)FindReplace for
CouchDeskDesktop
TableclothCarTruck
DesktopSofaCouch
TruckTableTablecloth

<tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"][/TD]

[TD="align: center"]3[/TD]

[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"][/TD]

[TD="align: center"]5[/TD]

[TD="align: right"][/TD]

</tbody>
Sheet2
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top