create required field in excel sheet/form

  • Thread starter Thread starter K. Elliot
  • Start date Start date
K

K. Elliot

I am wondering if there is an easy way to make certain fields within
an excel sheet required. I would like excel to display a message that
there were certain required fields that were left blank (and not be
able to close the file without the required fields).

I came across an item posted to this newsgroup on october 8, 2002 from
hank scorpio, but was unable to get it to work using the script he
posted.

Any assistance is greatly appreciated. Thanks.

Kevin
 
In the Workbook_BeforeClose event:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Application.CountA(Range("A3,B5,G4:G6")) <> 5 Then 'note there are
5 cells in this range -- adjust them to be YOUR required fields
MsgBox "required fields missing" 'Note-- maybe you want to
select them here as well
Cancel = True
End If
End Sub

Bob Umlas
Excel MVP
 

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