Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to present a messagebox to the user that allows him
to cancel and get completely out of the "program". Exit Sub is not enough because the messagebox has been called from another sub. How do I do this? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 27 Oct 2003 02:20:48 -0800, art <[email deleted] wrote:
I want to present a messagebox to the user that allows him to cancel and get completely out of the "program". Exit Sub is not enough because the messagebox has been called from another sub. How do I do this? Change the sub with the msgbox into a function, and instead of just calling it from the other sub, check its return value, which you set based on the return value of the msgbox. Here's an example: Sub bar() If Not foo Then Exit Sub 'or, assigned to a variable: y = foo If Not y Then Exit Sub 'or if y=false End Sub Function foo() As Boolean x = MsgBox("blah", vbOKCancel) If x = vbCancel Then foo = False Exit Function End If '... foo = True End Function -- auric "underscore" "underscore" "at" hotmail "dot" com ***** Professional wrestling: ballet for the common man. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sub routine | Excel Discussion (Misc queries) | |||
Worksheet_Change sub routine | New Users to Excel | |||
How to create a routine | Excel Discussion (Misc queries) | |||
Solver VBA routine | Excel Discussion (Misc queries) | |||
Need VBA Routine | Excel Programming |