Procedure loop limitation?
No limitation on loops. What you have is a recursive
subroutine. You've run out of stack space.
Re-write Procedure_Name2 to something like
Sub Procedure_Name2()
On Error Goto Err_Procedure_Name2
Do
'Perform an action on the active sheet then move to
next sheet
Do some other stuff
'Loop until error
Loop
err_Exit:
Exit Sub
Err_Procedure_Name2:
Resume err_Exit
End Sub
Be prepared to use the <Ctrl<Break keys in case it stays
in the loop
Kevin Beckham
-----Original Message-----
Hi,
I have created a macro (vba procedure) which runs when a
command button is
pressed on a spreadsheet. The procedure performs a
certain task then calls a
second procedure which runs in a continuous loop until it
reaches the end of
a series of active work sheets. At this point the second
procedure exits and
returns control to the first procedure.
An example
Sub Procedure_Name1()
Do something
Call Procedure_Name2
End Sub
Sub Procedure_Name2()
On Error Goto Err_Procedure_Name2
Do some other stuff 'Perform an action on
the active sheet
then move to next sheet
Call Procedure_Name2 'Loop until error
Err_Procedure_Name2:
Exit Sub
End Sub
This process works perfect but for some reason it stops
after looping 23
times i.e. 23 sheets are updated when the loop stops with
no error message.
Is there some restriction in VBA that prevents a
procedure from looping more
than 23 times.
Any help would be appreciated.
...pc
.
|