Hello, im trying to disable the save command in a document, I would like the user to be able to save the file only if some of the cells in sheet2 are
1.- not empty
2.- with the proper format for a few of those selected cells
if these conditions are not met, then display message "cannot be saved until..."
This is what i have, so far i can only do this for one cell, and i can only validate one condition.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Worksheets("Sheet2").Range("B5") = "Needs to be filled in" Then
Cancel = True
lReply = MsgBox("You cannot save until...", vbOKOnly)
Else
If Worksheets("Sheet2").Range("B5") = "Incorrect format" Then
Cancel = True
lReply = MsgBox("You cant save until correct format", vbOKOnly)
End If
End If
End Sub
The first one does work, but, other than that, if i try to extend the range, it wont compile.
Id apreciate some help in this matter, and i hope i made my self clear.
Thanks in advance
1.- not empty
2.- with the proper format for a few of those selected cells
if these conditions are not met, then display message "cannot be saved until..."
This is what i have, so far i can only do this for one cell, and i can only validate one condition.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Worksheets("Sheet2").Range("B5") = "Needs to be filled in" Then
Cancel = True
lReply = MsgBox("You cannot save until...", vbOKOnly)
Else
If Worksheets("Sheet2").Range("B5") = "Incorrect format" Then
Cancel = True
lReply = MsgBox("You cant save until correct format", vbOKOnly)
End If
End If
End Sub
The first one does work, but, other than that, if i try to extend the range, it wont compile.
Id apreciate some help in this matter, and i hope i made my self clear.
Thanks in advance