Repeating an action

S

Scott

I want to create a macro that does a set of instructions
one time. Now I may want to run that macro 4 times or
maybe 100 times in the same document and I dont want to
have to click a button 100 times to get my final result.
I could add a For/Next loop that would run the macro 100
times but I dont want to add For/Next loops to every new
macro. What I would like is to creat something that
repeats the next action a specified number of times. I
would click on a button that asks how many times I want
to do the next action, then I would run the macro and it
would do it how ever many times I specified.

Any thoughts?
 
G

geneus

Scott:

Use a For . . . Next Loop in combination with an InputBox:

The Input Box asks how many time you want to run it (Set the default to 1),
lets call it RunNum.

The captured variable RunNum is then used in the Loop:

For x = 1 to RunNum
Code....
Next x

Alternatively, depending on what you are doing, you can possibly use a Do .
.. . While loop.

-Gene
 

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