Loop macro

D

DNF Karran

If you add the following at the start and end of your code:

sub Loopy
for i = 0 to 1


Code
-------------------


next i
end sub

For more information look at the excel help- try searching for "Do Loop" and looking at "see also" for the various options you have.

Duncan
'excel.duncan-fiona.co.uk' (http://www.excel.duncan-fona.co.uk
 
H

Harald Staff

Like this

Sub test()
Static N As Long
If N >= 2 Then Exit Sub
N = N + 1
MsgBox N
Call test
End Sub

but it's pretty silly. The usual and reasonalbe way is like this:

Sub main()
Call test2
Call test2
End Sub

Sub test2()
MsgBox "Yo"
End Sub

HTH. Best wishes Harald
 
P

Peter Atherton

-----Original Message-----
Does anyone know of a way to loop a macro so it runs twice?
LB

Look at the Do While method on Help. This will run until a
condition is met.

Regards
Peter Atherton
 
Top