Hi,
I currently have a simple macro (see below) that requires users to input values in specific cells, otherwise it will not print or save.
However, I need to be able to leave the values blank before saving and sending to the user.
Any suggestions? I want to be able to save with blank cells, but once the user opens that document, I don't want them to also be able to save it blank (defeats the purpose of the first macro!).
Any help is appreciated, thanks!
PS I thought maybe there would be a way to request username and password, and based on username, the macro would override the macro preventing from saving without value in cell. I need to have a log in upon opening of the document anyways; just a thought.
MACRO used:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Sheets("Sheet1").Range("C15").Value = "" Then
MsgBox "C15 requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
If Sheets("Sheet1").Range("C16").Value = "" Then
MsgBox "C16requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheets("Sheet1").Range("C15").Value = "" Then
MsgBox "C15 requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
If Sheets("Sheet1").Range("C16").Value = "" Then
MsgBox "C16requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
End Sub
Private Sub Workbook_Open()
End Sub
I currently have a simple macro (see below) that requires users to input values in specific cells, otherwise it will not print or save.
However, I need to be able to leave the values blank before saving and sending to the user.
Any suggestions? I want to be able to save with blank cells, but once the user opens that document, I don't want them to also be able to save it blank (defeats the purpose of the first macro!).
Any help is appreciated, thanks!

PS I thought maybe there would be a way to request username and password, and based on username, the macro would override the macro preventing from saving without value in cell. I need to have a log in upon opening of the document anyways; just a thought.
MACRO used:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Sheets("Sheet1").Range("C15").Value = "" Then
MsgBox "C15 requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
If Sheets("Sheet1").Range("C16").Value = "" Then
MsgBox "C16requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheets("Sheet1").Range("C15").Value = "" Then
MsgBox "C15 requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
If Sheets("Sheet1").Range("C16").Value = "" Then
MsgBox "C16requires user input."
Cancel = True 'cancels the save event
Exit Sub
End If
End Sub
Private Sub Workbook_Open()
End Sub