Re: Find and Replace VBA help! by Doug
Doug
Thu Feb 16 15:37:29 CST 2006
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
"Mike" <Mike@discussions.microsoft.com> wrote in message
news:A679453D-C485-42EF-A2BD-712EDC56A2E1@microsoft.com...
> 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