I need to eliminate the specific number in the loop counter and make the macro stop running after all of the available replacements have been made no matter how few or how many replacements are on the page.
Quote
Go
Gt
Go
Gt
Go
Gt
Go
Gt
Go
Gt
Go
Gt
Go
Gt
Gt
Go
Gt
Go
Gt
Go
Gt
Go
Gt
Go
Gt
Go
Gt
Result Produced By Macro
Quote
LineNumber: 1LineNumber: 2
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8LineNumber: 9LineNumber: 10
Gp
Gp
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8LineNumber: 9LineNumber: 10
Gp
Gp
Result Wanted By Macro
Quote
LineNumber: 1
Gp
Gp
LineNumber: 2
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8
Gp
Gp
Gp
Gp
LineNumber: 2
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8
Gp
Gp
This page contains 14 replacements
Quote
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Result Produced By Macro
Quote
LineNumber: 1LineNumber: 2
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8
Gp
Gp
LineNumber: 9
Gp
Gp
LineNumber: 10
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8
Gp
Gp
LineNumber: 9
Gp
Gp
LineNumber: 10
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Go
Gp
Gp
Result Wanted By Macro
Quote
LineNumber: 1
Gp
Gp
LineNumber: 2
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8
Gp
Gp
LineNumber: 9
Gp
Gp
LineNumber: 10
Gp
Gp
LineNumber: 11
Gp
Gp
LineNumber: 12
Gp
Gp
LineNumber: 13
Gp
Gp
LineNumber: 14
Gp
Gp
Gp
Gp
LineNumber: 2
Gp
Gp
LineNumber: 3
Gp
Gp
LineNumber: 4
Gp
Gp
LineNumber: 5
Gp
Gp
LineNumber: 6
Gp
Gp
LineNumber: 7
Gp
Gp
LineNumber: 8
Gp
Gp
LineNumber: 9
Gp
Gp
LineNumber: 10
Gp
Gp
LineNumber: 11
Gp
Gp
LineNumber: 12
Gp
Gp
LineNumber: 13
Gp
Gp
LineNumber: 14
Gp
Gp
Here is the macro needing changes
Sub DoLoopDemo() ' ' DoLoopDemo Macro ' Macro created 7/3/2008 ' 'Loop: Do...Loop Demo: 'Selection.TypeText Text:="LineNumber: " 'Selection.TypeText Text:=intCounter Do While intCounter < 10 intCounter = intCounter + 1 Selection.Find.ClearFormatting With Selection.Find .Text = "Go" .Replacement.Text = intCounter .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Selection.TypeText Text:="LineNumber: " CycleCount = CycleCount + 1 Selection.TypeText Text:=CycleCount End With Selection.Find.Execute Loop End Sub
Thank you in advance for any replies.

New Topic/Question
This topic is locked




MultiQuote



|