ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how to have fields to be required (https://www.excelbanter.com/excel-worksheet-functions/190315-how-have-fields-required.html)

Mandatory fields in Excel

how to have fields to be required
 
I have an excel sheet that has fields we need to enter, (i.e. zipcode, State,
City), and what I want to know is HOW do I have it "mandatory" to have those
fields filled? Meaning if someone only fills 1 out of the 3 fields, then
tries to save it, it should prompt something like, "Please fill all fields
before saving", or something like that?

Gord Dibben

how to have fields to be required
 
You would need event code to cancel the save if all three cells were not filled.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI _
As Boolean, Cancel As Boolean)
If Application.CountA(Sheets("Sheet1").Range("A1:C1") ) < 3 Then
Cancel = True
MsgBox "Please fill required cells, save has been cancelled"
End If
End Sub

Note: if user disables macros the above won't run.


Gord Dibben MS Excel MVP

On Fri, 6 Jun 2008 08:43:02 -0700, Mandatory fields in Excel <Mandatory fields
in wrote:

I have an excel sheet that has fields we need to enter, (i.e. zipcode, State,
City), and what I want to know is HOW do I have it "mandatory" to have those
fields filled? Meaning if someone only fills 1 out of the 3 fields, then
tries to save it, it should prompt something like, "Please fill all fields
before saving", or something like that?




All times are GMT +1. The time now is 08:32 AM.

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