exit option to end macro

G

gregga

When several sub procedures are called one after another from the main
procedure I want to be able to exit the macro completely if one of them
fails.

The problem is that if I use an "if <condition fails> then exit sub" in
one of those sub procedures then the program passes back to the main
procedure and continues executing the rest.

As a newby I'm sure there is a fairly obvious answer to this but am
unable to find one unless I start "chaining" subs together which is a
fairly unorganised way to go about it.

Greg :)
 
D

Dave Peterson

Maybe you could rewrite your subs as functions and return a boolean value if
it's ok to continue:


sub test1()
dim okToContinue as boolean
oktocontinue = funct1()
if oktocontinue = false then
exit sub
end if
'more of the same...
end sub

function funct1() as boolean
'lots of code
if someerror then
funct1 = false
else
funct1 = true
end if
end function
 
Top