terminate a runnig macro
The only command that halts code execution is
END
by itself.
This is a Hard stop, so it is usually not advised to use it (see help on
this command).
Better would be to design your code to facilitate what you want.
Use an argument in you sub that contains an indicator to stop
Main
Dim bFlag as boolean
'code
'code
mysub bFlag
if bFlag then exit sub
' code
' code
End Sub
Sub Mysub(bHalt as Boolean)
if condition then
bHalt = True
else
bHalt = false
end if
End Sub
"JH" wrote in message
...
Thank you Tom,
but Exit Sub terminate only the procedure in which it is
and just following sub goes on
and I'need to terminate the whole macro not only one sub
Jan
"Tom Ogilvy" wrote:
if sth then
.....
else
exit sub
end if
application.quit
--
Regards,
Tom Ogilvy
"JH" wrote in message
...
hello everybody
I'd like to end a macro that is being executed
if sth then
....
else
macro would finish here
end if
application.quit
close an excel appl.
thanks
Jan
|