Macro - Repeat Action

  • Thread starter Thread starter Jan Groshan
  • Start date Start date
J

Jan Groshan

What is the command to repeat a macro in Word 2007? I want to run a macro on
a long list and want the macro to repeat 100+ times.
 
What is the command to repeat a macro in Word 2007? I want to run a macro on
a long list and want the macro to repeat 100+ times.

There is no specific command for that.

As an overly simplistic solution, you can write a second macro that calls the
first one in a loop, like

Sub Repeat100()
Dim i As Long
For i = 1 To 100
Call MyMacro
Next i
End Sub

Change "MyMacro" to the name of the macro you want to repeat.

The problem with this is that it always repeats 100 times. If that's too many or
too few, it isn't easy to adjust. A better solution is to modify your original
macro so the loop is inside it, and use a While loop or something of that sort
(instead of the fixed For loop) to stop looping when all the work is done.
Unfortunately, without knowing exactly what your macro does and how it does it,
I can't be any more specific than that.
 
THANKS !


Jay Freedman said:
There is no specific command for that.

As an overly simplistic solution, you can write a second macro that calls
the
first one in a loop, like

Sub Repeat100()
Dim i As Long
For i = 1 To 100
Call MyMacro
Next i
End Sub

Change "MyMacro" to the name of the macro you want to repeat.

The problem with this is that it always repeats 100 times. If that's too
many or
too few, it isn't easy to adjust. A better solution is to modify your
original
macro so the loop is inside it, and use a While loop or something of that
sort
(instead of the fixed For loop) to stop looping when all the work is done.
Unfortunately, without knowing exactly what your macro does and how it
does it,
I can't be any more specific than that.


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.
 
Back
Top