PC Review


Reply
Thread Tools Rate Thread

how do I tell a macro how many times to repeat

 
 
=?Utf-8?B?bGVl?=
Guest
Posts: n/a
 
      16th Feb 2006
After I've recorded a macro, how do I tell it how many times I want it to
repeat?
 
Reply With Quote
 
 
 
 
Charles Kenyon
Guest
Posts: n/a
 
      16th Feb 2006
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/...ordedMacro.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

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
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.


"lee" <(E-Mail Removed)> wrote in message
news:C3DE02F7-0D58-47B5-8763-(E-Mail Removed)...
> After I've recorded a macro, how do I tell it how many times I want it to
> repeat?



 
Reply With Quote
 
Greg
Guest
Posts: n/a
 
      16th Feb 2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeat list 5 times hab Microsoft Excel Misc 5 24th Apr 2009 09:37 PM
Repeat a macro until the last line is empty or repeat it 1400 time marita Microsoft Excel Programming 3 18th Jul 2008 01:40 PM
How to repeat a Macro multiple times? Jeff Mills Microsoft Word New Users 2 16th Mar 2006 08:21 PM
Macro: Ask user how many times to repeat =?Utf-8?B?QXJ5ZWhT?= Microsoft Word Document Management 2 19th Aug 2004 03:33 AM
Simply was to repeat a macro N times Joe Wooldridge Microsoft Excel Programming 2 25th Jul 2003 04:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:27 PM.