Hi All,
Leave Ken's workbook as is but change the close event to:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Turn off events to prevent unwanted loops
Application.EnableEvents = False
'Evaluate if workbook is saved and emulate default propmts
With ThisWorkbook
If Not .Saved Then
Select Case MsgBox("Do you want to save the changes you made to '" & .Name & "'?", _
vbYesNoCancel + vbExclamation)
Case Is = vbYes
'Call customized save routine
Call CustomSave
Case Is = vbNo
'Do not save
Case Is = vbCancel
'Set up procedure to cancel close
Cancel = True
End Select
End If
'If Cancel was clicked, turn events back on and cancel close,
'otherwise close the workbook without saving further changes
If Not Cancel = True Then
Application.EnableEvents = True
.Saved = True
If Not Workbooks.Count > 1 Then Application.Quit
Else
Application.EnableEvents = True
End If
End With
End Sub
This should prevent the look up.
You have an option to get rid of the flaw that ken mentioned in the thread about the workbook not closing excel as well (but it will close the application no matter which x is clicked so its up to you which flaw you'd rather have).
If you would rather have the flaw Ken mentioned then remove:
If Not Workbooks.Count > 1 Then Application.Quit
The problem with the lookup was events were being turned on and a close command given was causing a unwanted cycle.