Using a cell value in Search/Replace?

  • Thread starter Thread starter bimmerman
  • Start date Start date
B

bimmerman

Is there a way to do this?

I'm trying to record a Macro which will search on a set value an
replace it with a value from a cell.

Thanks
 
Press ALT+F11, Insert > Module, and paste this in. Flip
back to Excel, select the range, and then run the macro
from Tools > Macros. C1 = value to find, D1 = value to
replace with:

Sub FindReplace()

Dim fvalue As Range
Dim rvalue As Range

Set fvalue = Range("C1")
Set rvalue = Range("D1")

With Selection
.Replace What:=fvalue, Replacement:=rvalue
End With
End Sub
 
Back
Top