nightcrawler23
Well-known Member
- Joined
- Sep 24, 2009
- Messages
- 721
I am using a userform in which i have an exit button which removes some sheets and exits after saving the workbook.
I am also using the same thing as an workbook before close event but when i exit using button it also displays the befoeclose event message
see the code below
I want that if exit btn is used the beforeclose event is disabled
help!!!!!!!!
I am also using the same thing as an workbook before close event but when i exit using button it also displays the befoeclose event message
see the code below
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
resp = MsgBox("Do you want to remove the RAO Sheets?", 4)
If resp = 6 Then
removeSheets
Workbooks("Motion Analysis.xls").Close savechanges:=True
End If
End Sub
Code:
Private Sub CmdExit_Click()
If (Sheets("sheet1").Cells(1, 3) = 1) Then
ans = MsgBox("The Data Will be Erased" & vbCrLf & "Have you saved The Data", 4, "Exit Application")
If ans = 6 Then
removeSheets
Workbooks("Motion Analysis.xls").Close savechanges:=True
Else
MsgBox ("Please Save Your Data")
End If
Else
removeSheets
Workbooks("Motion Analysis.xls").Close savechanges:=True
End If
End Sub
I want that if exit btn is used the beforeclose event is disabled
help!!!!!!!!