Msgbox not working
When you use an event it must match the event signature specified by VBA
and be in the correct code sheet. The BeforeSave event must be in the
ThisWorkbook module and should look something like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim ans As Long
ans = MsgBox("Did you enter the dates?", vbYesNo)
If ans = vbNo Then
Cancel = True
MsgBox "File not saved"
End If
End Sub
Hope this helps
Rowan
davegb wrote:
I wrote the following to remind users to enter dates when they save the
worksheet/book:
Private Sub Workbook_BeforeSave()
MsgBox "Did you enter the dates?"
End Sub
But the message box doesn't show. The macro is in the sheet I'm saving.
Any ideas?
Thanks!
|