how do I tell a macro how many times to repeat

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

After I've recorded a macro, how do I tell it how many times I want it to
repeat?
 
By coding repetition into your macro. You can't record this, you have to go
into the vba editor and write computer code.
http://word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

What is your macro doing? There may be a better tool than a macro.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
If you want to repeat an entire macro a certain number of time, you
would need to call it that number of time. For example the following
code calls the macro named "CountDown" ten times:

Sub Test()
Dim i As Long
For i = 1 To 10
CountDown i
Next i
MsgBox "We have a liftoff."
End Sub
Sub CountDown(i As Long)
MsgBox "T-" & 11 - i & " seconds and counting."
End Sub

If your macro is performing a specific steps and you want to repeat
that step you would use a similiar construction to repeat the step:

Sub Test()
Dim i As Long
MsgBox "T-10 seconds. We have main motor start."
For i = 1 To 9
MsgBox "T-" & 10 - i
Next i
MsgBox "We have a liftoff."
End Sub
 

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

Back
Top