Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My codes is writen in a way that if a conditon is met in Sub1 I want to exit
ExitSub, is this possible? Sub ExitSub() Call Sub1 Call Sub2 Call Sub3 End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use functions instead of Sub1, Sub2 etc., then the Function return value
can be set True if you need to exit. Sub ExitSub If Function1 then ExitSub If Function2 then ExitSub End Sub Function Function1() As Boolean ' set return to True if you want to Exit main sub Function1 = True End Function -- Regards, Nigel "RyanH" wrote in message ... My codes is writen in a way that if a conditon is met in Sub1 I want to exit ExitSub, is this possible? Sub ExitSub() Call Sub1 Call Sub2 Call Sub3 End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
This passes the variable x between subs. If x is set to 1 then ExitSub terminates. For example in the code below ExitSub terminates after Sub1 has run. BTW no need for Call Public x Sub ExitSub() x = 0 sub1 If x = 1 Then Exit Sub sub2 sub3 End Sub Sub sub1() x = 1 MsgBox "In sub1" End Sub Sub sub2() MsgBox "In sub2" End Sub Sub sub3() MsgBox "In sub3" End Sub "RyanH" wrote: My codes is writen in a way that if a conditon is met in Sub1 I want to exit ExitSub, is this possible? Sub ExitSub() Call Sub1 Call Sub2 Call Sub3 End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You did NOT post your code for comments as you ALWAYS should. Here is an
example where you could put em together. A select case would probably be even better. Sub exitif() Call subone 'called after sub one is over Call subtwo End Sub Sub subone() For Each c In Range("h1:h13") MsgBox c If c = 15 Then MsgBox "found it" Exit Sub End If Next c End Sub Sub subtwo() For Each c In Range("h1:h13") MsgBox c If c = 14 Then MsgBox "found it" Exit Sub End If Next c End Sub Sub putemtogether() For Each c In Range("h1:h13") MsgBox c If c = 15 Then MsgBox "found it" Exit Sub End If If c = 14 Then MsgBox "found it" Exit Sub End If Next c End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "RyanH" wrote in message ... My codes is writen in a way that if a conditon is met in Sub1 I want to exit ExitSub, is this possible? Sub ExitSub() Call Sub1 Call Sub2 Call Sub3 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Exit Sub not exiting | Excel Programming | |||
exiting the whole macro | Excel Programming | |||
exiting program | Excel Programming | |||
Exiting Worksheet | Excel Discussion (Misc queries) | |||
Exiting a workbook | Excel Programming |