ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   In Excel, how to make a field required so it's not left blank? (https://www.excelbanter.com/excel-programming/363305-excel-how-make-field-required-so-its-not-left-blank.html)

linplex

In Excel, how to make a field required so it's not left blank?
 
I've seen a lot of advise, however I need complete, step-by-step
instructions. Thanks!

Chip Pearson

In Excel, how to make a field required so it's not left blank?
 
I assume you want to ensure that a cell is filled out before the
workbook is closed. Open the VBA Editor, display the Project
Window (CTRL+R) and open the ThisWorkbook code module. There,
paste the following code:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Worksheets("Sheet1").Range("A1").Value = "" Then
MsgBox "You must fill in A1."
Cancel = True
End If
End Sub


Change the Sheet name and cell reference to meet your needs.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"linplex" wrote in message
...
I've seen a lot of advise, however I need complete,
step-by-step
instructions. Thanks!





All times are GMT +1. The time now is 02:04 PM.

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