Hi, I've been using this code to make sure a document cannot be saved without the required information being filled in, but I wondered if there is a way to make it a little smarter.
It would be best if it was something like "If C4 contains information, then C5, B6 must". It would be good if a window popped up as well, stating that the related cells need to have information entered. I've searched the forum, but I haven't found anything directly related this this yet. Any input would be appreciated!
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cellcontents = Sheets(1).Range("B3").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell B3 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("B4").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell B4 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("B6").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell B6 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
End Sub
Bookmarks