Thread: Macro-replace
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
puiuluipui puiuluipui is offline
external usenet poster
 
Posts: 468
Default Macro-replace

Hi, my first post was a little bit wrong.
I need to change a few cities with a name:

Atlanta; New York; Denver to Jim
Las Vegas, Detroit; Washington to John
Chicago; Ohio, Los Angeles to Mary

Sorry for my first post.
Can this be done?
Thanks!

"Mike H" wrote:

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!