Excel 2003
Hi, i've written some code in the workbook beforesave to make certain fields mandatory as below:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
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("D4").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell D4 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("F4").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell F4 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("C6").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell C6 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("E6").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell E6 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
End Sub
However a problem i have found is that you can't save this say if you was just administering this workbook. So an idea i had was to have a password cell, so that before save if this cell had a particular string in there then you could save without having to fill in the mandatory fields, and then on open of the workbook this password field would be cleared, however i'm not sure how to do this. Any help?
Hi, i've written some code in the workbook beforesave to make certain fields mandatory as below:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
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("D4").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell D4 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("F4").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell F4 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("C6").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell C6 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
Cellcontents = Sheets(1).Range("E6").Value
If Cellcontents = "" Then
Cancel = True
MsgBox "Cell E6 is empty - Not Saving!", vbOKOnly, "Check Cells"
Exit Sub
End If
End Sub
However a problem i have found is that you can't save this say if you was just administering this workbook. So an idea i had was to have a password cell, so that before save if this cell had a particular string in there then you could save without having to fill in the mandatory fields, and then on open of the workbook this password field would be cleared, however i'm not sure how to do this. Any help?