G
Greg
I am reviewing my code looking for efficiencies.
The code looks for text, counts occurrences, and "if" the
user elects, it will highlight each occurrence.
Here is a bit of code that is working, but seems
inefficient:
Do While .Execute = True
If pHlight = vbYes Then
rngStory.HighlightColorIndex _ =
Options.DefaultHighlightColorIndex
rngStory.Collapse wdCollapseEnd
End If
pCount = pCount + 1
Loop
Since pHight is set before the Do ... Loop starts, and
won't change during the Loop am I not wasting time
checking it each run through the Loop?
Would it be more efficient to have two Do ... Loops in an
IF Else statement like this:
If pHlight = vbYes Then
Do While .Execute = True
rngStory.HighlightColorIndex _ =
Options.DefaultHighlightColorIndex
rngStory.Collapse wdCollapseEnd
pCount = pCount + 1
Loop
Else: Do While .Execute = True
pCount = pCount + 1
Loop
End If
I think I am asking a stupid question with an obvious
answer. Just looking for confrimation that I am on the
right track here or a recommendation for a better way.
The code looks for text, counts occurrences, and "if" the
user elects, it will highlight each occurrence.
Here is a bit of code that is working, but seems
inefficient:
Do While .Execute = True
If pHlight = vbYes Then
rngStory.HighlightColorIndex _ =
Options.DefaultHighlightColorIndex
rngStory.Collapse wdCollapseEnd
End If
pCount = pCount + 1
Loop
Since pHight is set before the Do ... Loop starts, and
won't change during the Loop am I not wasting time
checking it each run through the Loop?
Would it be more efficient to have two Do ... Loops in an
IF Else statement like this:
If pHlight = vbYes Then
Do While .Execute = True
rngStory.HighlightColorIndex _ =
Options.DefaultHighlightColorIndex
rngStory.Collapse wdCollapseEnd
pCount = pCount + 1
Loop
Else: Do While .Execute = True
pCount = pCount + 1
Loop
End If
I think I am asking a stupid question with an obvious
answer. Just looking for confrimation that I am on the
right track here or a recommendation for a better way.