BeforeSave and Close help
Thanks for your help, but I'm somewhat of a novice and this doesn't really
make sense to me. I tried the code the code you suggested, which doesn't
work. You told me not to use the BeforeSave code I have so where do I check
to see if my cells have the correct value? Thanks
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim msg As String
Dim Ans As Variant
Dim wb As Workbook
msg = "Do you want to save the changes to "
'msg = msg & wb.Name & "?"
Ans = MsgBox(msg, vbQuestion + vbYesNoCancel)
Select Case Ans
Case vbYes
wb.Save 'suppresses default alert
wb.Close
Case vbNo
wb.Saved = True 'suppresses default alert
wb.Close
Case vbCancel
Cancel = True 'returns to Excel
End Select
End Sub
"GS" wrote:
Alex,
Sorry I forgot to mention, ..the previous code sample should be called from
the BeforeClose event for your workbook. Also, using the BeforeSave event is
pointless for this situation so don't use it.
Regards,
GS
|