Nutterhead
New Member
- Joined
- Apr 25, 2017
- Messages
- 27
Hello wonderful helpers,
I have a VBA code I'm trying to write that will allow users to click a button and that will save and close the workbook every time but if it's the final save for the end of the day will look at cell M6 to see if it's empty or not. If it's empty I need the sub to exit without saving and closing giving a message that it must have a verification name. The Cell does not have a formula or anything in it but is based off a data validation list. I can't seem to figure it out correctly below is what I currently have.
Sub Save_and_Close()
Dim ans As String, lr As Long
ans = MsgBox("Is this the final save before upload?", vbYesNo)
If ans = vbYes & IsEmpty(M6) Then
MsgBox ("Must Have Verification Name")
Exit Sub
Else
ThisWorkbook.Save
MsgBox ("Your data has been saved."), vbInformation
Application.Quit
End If
End Sub
I have a VBA code I'm trying to write that will allow users to click a button and that will save and close the workbook every time but if it's the final save for the end of the day will look at cell M6 to see if it's empty or not. If it's empty I need the sub to exit without saving and closing giving a message that it must have a verification name. The Cell does not have a formula or anything in it but is based off a data validation list. I can't seem to figure it out correctly below is what I currently have.
Sub Save_and_Close()
Dim ans As String, lr As Long
ans = MsgBox("Is this the final save before upload?", vbYesNo)
If ans = vbYes & IsEmpty(M6) Then
MsgBox ("Must Have Verification Name")
Exit Sub
Else
ThisWorkbook.Save
MsgBox ("Your data has been saved."), vbInformation
Application.Quit
End If
End Sub