User to decide how often a macro runs

D

Deedee

Can anyone help...Please.... I need a macro that asks for the user to input
the number of times it needs to run. Thanks for any help in advance
 
C

Chip Pearson

Try something like the following:

Dim NumRuns As Long
Dim Ndx As Long
NumRuns = Application.InputBox(prompt:="Enter number of times.",
_
Type:=1)
For Ndx = 1 To NumRuns
' run your macro code here
Next Ndx


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
H

Harald Staff

One way among several:

Sub test()
Dim L As Long, X As Long
L = Application.InputBox("Pick a number:", Type:=1)
For X = 1 To L
Call SubProc(X, L)
Next
End Sub

Sub SubProc(L As Long, LMax As Long)
MsgBox "Yo da man !", vbExclamation, L & " of " & LMax
End Sub

HTH. Best wishes Harald
 
Top