Rich (BB code):
Option Explicit
Option Base 1
Sub DeleteSheets_Warning()
Dim iRet As Integer
Dim strPrompt As String
Dim strTitle As String
' Promt
strPrompt = "You are about to DELETE selected worksheets !" & vbCr & vbCr & _
" Are you sure you want to delete" & vbCr & vbCr & _
" the sheets you have selected in Column C? "
' Dialog's Title
strTitle = "DELETE SHEETS"
'Display MessageBox
iRet = MsgBox(strPrompt, vbYesNo + vbCritical + vbSystemModal, strTitle)
' Check pressed button
If iRet = vbNo Then
MsgBox " NO!"
Exit Sub
ElseIf iRet = vbYes Then
MsgBox " Yes!"
DeleteSheets_Claus
End If
End Sub
This works just fine but for one exception.
If the user gets to the MsgBox as noted in red and decided to cancel out with the X icon in the very upper right, it still calls DeleteSheets_Claus.
I want to exit sub when this happens but don't know how to code:
If MsgBox upper right X icon clicked then exit sub
Thanks.
Howard