ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Excel Spreadsheet - Mandatory fields (https://www.excelbanter.com/excel-worksheet-functions/82164-excel-spreadsheet-mandatory-fields.html)

Mike in Philly

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

Bob Phillips

Excel Spreadsheet - Mandatory fields
 
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)

"Mike in Philly" <Mike in wrote in message
...
Is there a way to make an Excel spreadsheet not be able to close unless
certain fields are filled in?





All times are GMT +1. The time now is 11:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com