Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have UserForm1, that when completed, and the user clicks the OK
button, opens up UserForm2. I also have a Cancel option in UserForm1. Right now, if Cancel is clicked, the macro will still continue on to UserForm2. That's because the only code I have in the Cancel sub is to close UserForm1. I want it to stop the whole macro when Cancel is selected. What is the correct code I should enter in the Cancel sub to make the whole macro stop? Thanks, J.O. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Why not just Unload the other from as well?
-- HTH RP "excelnut1954" wrote in message ups.com... I have UserForm1, that when completed, and the user clicks the OK button, opens up UserForm2. I also have a Cancel option in UserForm1. Right now, if Cancel is clicked, the macro will still continue on to UserForm2. That's because the only code I have in the Cancel sub is to close UserForm1. I want it to stop the whole macro when Cancel is selected. What is the correct code I should enter in the Cancel sub to make the whole macro stop? Thanks, J.O. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() In the userform: Private Sub cmdExit_Click() Call exitMacro End Sub In the Main Module (for reference by both userforms if necessary...._ Public Sub exitMacro() ' quit the macro and exit Excel Dim msg, style, title, response If langChoice = "English" Then msg = "If you exit the application, any unsaved data or documents" _ & vbCrLf & " will be lost. Are you sure you wish to Exit?" title = "Please confirm selected action." style = vbYesNo + vbQuestion + vbDefaultButton1 + vbApplicationModal response = MsgBox(msg, style, title) End If If response = vbYes Then exitNo = 0 Application.Quit End ElseIf response = vbNo Then exitNo = 1 End If End Sub The message box is just a polite way of reminding the user, they'll lose everything if they quit. -- ljsmith ------------------------------------------------------------------------ ljsmith's Profile: http://www.excelforum.com/member.php...o&userid=30531 View this thread: http://www.excelforum.com/showthread...hreadid=501832 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to get userform Cancel button to invoke Exit Sub in calling macro? | New Users to Excel | |||
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work | Setting up and Configuration of Excel | |||
Cancel Macro is user selects 'cancel' at save menu | Excel Programming | |||
Cancel Button | Excel Programming | |||
Button To Cancel Macro | Excel Programming |