Excel Spreadsheet - Mandatory fields

M

Mike in Philly

Is there a way to make an Excel spreadsheet not be able to close unless
certain fields are filled in?
 
B

Bob Phillips

You could put something in the BeforeClose event

Private Sub Workbook_BeforeClose(Cancel As Boolean)

With Worksheets("Sheet1")
If .Range("A1").Value = "" Then
MsgBox "Value not supplied"
Cancel = True
End If
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
Top