Thread: Macro-replace
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Macro-replace

Hi,

You don't need a macro for this you can simply do a search/replace but as
you asked for a macro, try this

Sub Sonic()
Dim RepString As Variant
Dim FindString As Variant
FindString = "Jim,John,Mary"
RepString = "Atlanta,Las Vegas,Chicago"
s = Split(FindString, ",")
t = Split(RepString, ",")
For x = 0 To UBound(s)
Cells.Replace What:=s(x), Replacement:=t(x), LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Next
End Sub

Mike

"puiuluipui" wrote:

Hi, i need a macro to replace:
Jim with Atlanta
John with Las Vegas
Mary with Chicago
.....
This criteria to be inside macro.
Can this be done?
Thanks!