redspanna
Well-known Member
- Joined
- Jul 27, 2005
- Messages
- 1,604
- Office Version
- 365
- Platform
- Windows
Hi all
I have a Userform that on selecting YES a certain macro is run on selecting NO the form is closed and the workbook closed...or at least that is what I want..
code attached to the NO button on the userform
however there is also this code in the Workbook_BeforeClose(Cancel As Boolean) section
so an error occurs because as I understand it when the NO button is pressed the userform is closed but then the private Sub code above kicks is
How can I over ride this on close event so that when the NO button is selected the userform is closed and the workbook is closed too without running the Private Sub Workbook_BeforeClose(Cancel As Boolean) macro
hope this makes sense and thanks in advance
I have a Userform that on selecting YES a certain macro is run on selecting NO the form is closed and the workbook closed...or at least that is what I want..
code attached to the NO button on the userform
Code:
Private Sub CommandButton2_Click()
Unload Me
ActiveWorkbook.Close
End Sub
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim myForm As Userclose
If Time > TimeValue("18:00:00") Then
Cancel = True
Set myForm = Userclose
myForm.Show
End If
End Sub
so an error occurs because as I understand it when the NO button is pressed the userform is closed but then the private Sub code above kicks is
How can I over ride this on close event so that when the NO button is selected the userform is closed and the workbook is closed too without running the Private Sub Workbook_BeforeClose(Cancel As Boolean) macro
hope this makes sense and thanks in advance