Can I make cell completion mandatory in excel?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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).
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top