View Single Post
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Greg
 
Posts: n/a
Default how do I tell a macro how many times to repeat

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