Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try this
if something then exit sub------------<in one line some other code ------------ no need of end if, no need of else if the first line is in one line if something is not, then automatically it goes to the next line. try and see. 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks
Jan "Tom Ogilvy" wrote: 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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Then you need to set up a module level variable, say StopNow, and at the place
where you want to stop you write Sub3(...) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
terminate a form | Excel Discussion (Misc queries) | |||
Runnig a macro when excel opens | Excel Programming | |||
Runnig macros in background mode | Excel Programming | |||
Runnig macros in background mode | Excel Programming | |||
Can't terminate the excel instance from VB | Excel Programming |