Find & Replace

B

blackbird4280

Hi,
I want to write a vba that allows me to perform a find & replace
limited in a specific part of the text: every time I meet a keyword
"Start", I want to begin to replace all the "A" with "B", until I meet
the other keyword "Stop".
Can you help me?
Thanks,
ML
 
F

Fumei2 via OfficeKB.com

What have you got so far?
Hi,
I want to write a vba that allows me to perform a find & replace
limited in a specific part of the text: every time I meet a keyword
"Start", I want to begin to replace all the "A" with "B", until I meet
the other keyword "Stop".
Can you help me?
Thanks,
ML
 
D

Doug Robbins - Word MVP

Use:

Dim myrange As Range
Set myrange = ActiveDocument.Range
myrange.Start = myrange.Start + InStr(myrange, "Start")
myrange.End = myrange.Start + InStr(myrange, "Stop")
myrange.Select
myrange.Text = Replace(myrange.Text, "A", "B")


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
B

blackbird4280

Use:

Dim myrange As Range
Set myrange = ActiveDocument.Range
myrange.Start = myrange.Start + InStr(myrange, "Start")
myrange.End = myrange.Start + InStr(myrange, "Stop")
myrange.Select
myrange.Text = Replace(myrange.Text, "A", "B")

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

It works fine,
I was not able to define properly the range...
Thanks a lot!
Bye,
ML
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top