I heart Excel
Board Regular
- Joined
- Feb 28, 2011
- Messages
- 66
Hello,
I am trying to make cells within Excel 2007 mandatory before the user can save.
I have had a look online and so far found -
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheets("Sheet1").Range("B5").Value = "" Then
MsgBox "Please enter value in B5"
Cancel = True 'cancels the save event
End If
End Sub
This works fine, but I have a few additional things that I have looked around for but can't seem to get to work! I need to be able to save the document after putting this into VBA, but can't as I keep getting the error about the mandatory cells! Also I have random cells (a range) that need to be filled out. not just one.
Can anyone help?
Thanks
I am trying to make cells within Excel 2007 mandatory before the user can save.
I have had a look online and so far found -
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheets("Sheet1").Range("B5").Value = "" Then
MsgBox "Please enter value in B5"
Cancel = True 'cancels the save event
End If
End Sub
This works fine, but I have a few additional things that I have looked around for but can't seem to get to work! I need to be able to save the document after putting this into VBA, but can't as I keep getting the error about the mandatory cells! Also I have random cells (a range) that need to be filled out. not just one.
Can anyone help?
Thanks