Can I make cell completion mandatory in excel?

J

Jason Morin

You can set up your workbook so that it will not allow
the user to close the workbook without filling in certain
cell. For example:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim checkRng As Range
Set checkRng = Sheets("Sheet1").Range("A1")
If checkRng.Value = "" Then
Cancel = True
MsgBox "Please fill in " & _
checkRng.Address(False, False) & "."
End If
End Sub

---
Place this in the ThisWorkbook module of your workbook.

HTH
Jason
Atlanta, GA
 
D

Dave Peterson

Just a thought...

Maybe this would be better in the _beforeSave event.

Then the user can open and close without having to fill in A1.

And with the _beforeclose event, I can save with A1 empty, fill in A1, close
(without saving).
 
J

Jason Morin

Yes, I wasn't sure which event made more sense. I suppose
if I had tested them both I would have reached the same
conclusions.
 
Top