I'm trying to email the spreadsheet on close, but I also have some other code to fit in and I'm not sure where to put it.
Private Sub Workbook_BeforeClose(cancel As Boolean)
x = MsgBox("Have you updated the Version Log", vbYesNo)
If x = vbYes Then Application.Dialogs(xlDialogSendMail).Show
Exit Sub
If x = vbNo Then cancel = True
MsgBox ("Please Update Version Log")
Sheets("Version Log").Select
Range("B5").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
Application.Dialogs(xlDialogSendMail).Show
End Sub
I know where the problem is, its the exit sub after the vbYes, It works fine if the answer is yes, it emails fine. But if the answer is no, it still opens the email to send and I dont want this. What is the best way to do it?
thanks
Private Sub Workbook_BeforeClose(cancel As Boolean)
x = MsgBox("Have you updated the Version Log", vbYesNo)
If x = vbYes Then Application.Dialogs(xlDialogSendMail).Show
Exit Sub
If x = vbNo Then cancel = True
MsgBox ("Please Update Version Log")
Sheets("Version Log").Select
Range("B5").Select
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
Application.Dialogs(xlDialogSendMail).Show
End Sub
I know where the problem is, its the exit sub after the vbYes, It works fine if the answer is yes, it emails fine. But if the answer is no, it still opens the email to send and I dont want this. What is the best way to do it?
thanks