Macro - Repeat Action

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

Jay Freedman

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

Jan Groshan

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.
 

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