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:
Thanks a lot!!!
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!!!