Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / April 2008

Tip: Looking for answers? Try searching our database.

Replace several words to One

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wanna Learn - 30 Apr 2008 13:11 GMT
Hello  How do I correct the macro below.  I want to change the words FXG,
FXR, GFX, and FXT  to say FAX
Thank you thank you

 Range("C1:C3169").Select
   Selection.Replace What:=("FXG""FXR""GFX""FXT")Replacement:="FAX",
LookAt:=xlPart, _
       SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
       ReplaceFormat:=False
End Sub
Tom Hutchins - 30 Apr 2008 13:54 GMT
One way...

Sub AAA()
Range("C1:C3169").Select
Call ReplaceText("FXG", "FAX")
Call ReplaceText("FXR", "FAX")
Call ReplaceText("GFX", "FAX")
Call ReplaceText("FXT", "FAX")
End Sub

Sub ReplaceText(FromTxt As String, ToTxt As String)
Selection.Replace What:=FromTxt$, Replacement:=ToTxt$, LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
End Sub

Hope this helps,

Hutch

> Hello  How do I correct the macro below.  I want to change the words FXG,
> FXR, GFX, and FXT  to say FAX
[quoted text clipped - 6 lines]
>         ReplaceFormat:=False
> End Sub
Dave Peterson - 30 Apr 2008 13:56 GMT
dim myWords as Variant
dim wCtr as long

myWords = array("FXG","FXR","GFX","FXT")

for wctr = lbound(mywords) to ubound(mywords)
  activesheet.range("c1:C3169").replace what:=mywords(wctr), _
       replacement:="FAX", lookat:=xlPart, SearchOrder:=xlByRows, _
       MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
next wctr

> Hello  How do I correct the macro below.  I want to change the words FXG,
> FXR, GFX, and FXT  to say FAX
[quoted text clipped - 6 lines]
>         ReplaceFormat:=False
> End Sub

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.