View Full Version : repeating macro


JasonLevan
01-27-2011, 12:28 PM
I have the following macro
Sub TestMacro()
Range("A2").Select
ActiveCell.FormulaR1C1 = InputBox("Item Number")
Range("B2").Select
ActiveCell.FormulaR1C1 = InputBox("Qty #")
Range("C2").Select

End Sub
it works fine but i want it to repeat itself over and over until I end like the word end or stop or press a number. Any way to do such a thing

pbaldy
01-27-2011, 12:49 PM
Untested, but try

Sub TestMacro()
Do While 1=1
If InputBox("Stop yet?") = "stop" Then
Exit Do
End If

Range("A2").Select
ActiveCell.FormulaR1C1 = InputBox("Item Number")
Range("B2").Select
ActiveCell.FormulaR1C1 = InputBox("Qty #")
Range("C2").Select
Loop
End Sub

You could also test one of your existing InputBox results if you wanted.

JasonLevan
01-31-2011, 12:12 PM
good start but I dont want it to ask me if i want to stop every time, can it just notice the "stop command" if i enter it into the item number field

pbaldy
01-31-2011, 12:47 PM
Like I said:

You could also test one of your existing InputBox results if you wanted.