ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Mandatory Cells (https://www.excelbanter.com/excel-worksheet-functions/125245-mandatory-cells.html)

doorguy

Mandatory Cells
 
I want to make a specific cell on a spread sheet I've created mandatory
before the document can be saved. For example; L2 must have a data entry
before document can be saved.

Is this possible, if so, how do I do it.


Nick Hodge

Mandatory Cells
 
Doorguy

You could put some workbook_beforesave() event code in the ThisWorkbook
module, like so

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Worksheets("Sheet1").Range("L2").Value = "" Then
MsgBox "Sheet1 Cell L2 must have an entry, save aborted", vbOKOnly +
vbInformation, "Error"
Cancel = True
End If
End Sub

To implement right click the Excel icon near the top left of the window and
select view code, paste the code here, change the sheet name as necessary
and save the file

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"doorguy" wrote in message
...
I want to make a specific cell on a spread sheet I've created mandatory
before the document can be saved. For example; L2 must have a data entry
before document can be saved.

Is this possible, if so, how do I do it.




All times are GMT +1. The time now is 12:39 AM.

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