Find and Replace VBA help!

M

Mike

Hello all,

I hope you're having a great day.

I have a problem and I'm hoping that somebody can help me:

I have a line that appears 1300 times in a document: "enter the
corresponding test case ####" that I need replaced with values I now have.
Each time that the line is found, I need to replace the line with an
incrementing value (first one is 1, the second is 2, third is 3 etc).

Is there an easy VBA function that will perform this?

I'd really appreciate any and all help,

Mike
 
D

Doug Robbins - Word MVP

Use a macro containing the following code

Dim i As Long
i = 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="####", MatchWildcards:=False,
Wrap:=wdFindContinue, Forward:=True) = True
Selection.Range.Text = i
i = i + 1
Loop
End With


--
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
 

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