Macro to Replace content of a cell.

jbesclapez

Active Member
Joined
Feb 6, 2010
Messages
275
Hello Mr Excel, :biggrin:

I have a range from A:G
I have a column in I that tells what to find in the range
I have a column in J that tells with what to replace.
Those find/replace are in front of each other so : I1 is replaced by J1, I2 is replace by J2...
The find/replace as match the full content of the cell.

I hope my description is clear enough.

Thanks for your precious help.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub Replacements()
  Dim X As Long, FindReplace As Variant
  FindReplace = Range("I1", Cells(Rows.Count, "J").End(xlUp))
  For X = 1 To UBound(FindReplace)
    Columns("A:G").Replace FindReplace(X, 1), FindReplace(X, 2), xlWhole, , [B][COLOR="#FF0000"]True[/COLOR][/B], , False, False
  Next
End Sub[/td]
[/tr]
[/table]
Note: I assumed the values being searched for must be an exact match including the upper/lower case of the letters. If that guess was wrong, then change the red True highlighted above to False.
 
Last edited:
Upvote 0
Give this macro a try...
Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Sub Replacements()
  Dim X As Long, FindReplace As Variant
  FindReplace = Range("I1", Cells(Rows.Count, "J").End(xlUp))
  For X = 1 To UBound(FindReplace)
    Columns("A:G").Replace FindReplace(X, 1), FindReplace(X, 2), xlWhole, , [B][COLOR=#FF0000]True[/COLOR][/B], , False, False
  Next
End Sub[/TD]
[/TR]
</tbody>[/TABLE]
Note: I assumed the values being searched for must be an exact match including the upper/lower case of the letters. If that guess was wrong, then change the red True highlighted above to False.

Hello Rick,

What you did is perfect. Thanks a lot.
I am always amazed with the apparent simplicity of your work. You manage to make a difficult thing look simple in few lines.
Thanks again Rick, I wish you a great day
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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