Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dht dht is offline
external usenet poster
 
Posts: 4
Default Running a Sub and exiting the current one.

I have a message box and on the VbNo command I want to run another
code and exit the current Sub.

How do I do this.

Thanks
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Running a Sub and exiting the current one.


This is a way to do it:

But it depends whether the procedure it nested inside
another loop... (which needs to be made aware of how the called
procedure progressed..and I'd use a module boolean variable for that.

if it's NOT a 'nested' call you can do without the boolean

dim bCancel as boolean

Sub main()
bCancel=false
proc1
if bcancel then proc3
end sub

sub proc1()
if vbno=msgbox("continue",vbyesno) then
msgbox "oops"
bCancel=true
proc2
exit sub
else
Msgbox "I'll get to work"
endif
'code continues here

end sub

sub proc2
msgbox "I'll do the cleanup"
end sub
sub proc3
msgbox "I'll make the report"
end sub


hope this was clear...
(though it does look hasty :)



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


(dht) wrote:

I have a message box and on the VbNo command I want to run another
code and exit the current Sub.

How do I do this.

Thanks
David


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Running a Sub and exiting the current one.

Dim res as Variant ' or long
res = Msgbox("Click yes or no", vbYesNo)
if res = vbNo then
Macro1
exit sub
else
msgbox "You said yes"
End if

--
Regards,
Tom Ogilvy

"dht" wrote in message
om...
I have a message box and on the VbNo command I want to run another
code and exit the current Sub.

How do I do this.

Thanks
David



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running total based upon current date ucastores Excel Worksheet Functions 5 April 10th 10 04:48 PM
Exiting Excel MEAD5432 Excel Discussion (Misc queries) 2 December 7th 07 11:05 PM
Running/Current time in cell? SRS New Users to Excel 6 September 28th 05 09:45 PM
Exiting Worksheet Evan Excel Discussion (Misc queries) 1 February 11th 05 06:06 PM
Exiting a workbook John Wilson Excel Programming 0 August 15th 03 04:43 PM


All times are GMT +1. The time now is 02:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"