ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I create a mandatory field in Excel (https://www.excelbanter.com/excel-programming/377863-how-do-i-create-mandatory-field-excel.html)

RSP

How do I create a mandatory field in Excel
 
I would like to set a field in Excel to be mandatory. I want it to not go to
the next field unless data is entered. O

Alok

How do I create a mandatory field in Excel
 
Say your mandatory field is Cell A1. Then put the following in the
Worksheet Change event of the sheet

Private Sub Worksheet_Change(ByVal Target As Range)
If (Intersect(Target.Cells(1), Range("A1")) Is Nothing) Then
If Trim(Range("A1").Text) = "" Then
MsgBox "Please enter a value in cell A1 before proceeding"
Application.EnableEvents = False
Target.Cells.Clear
Application.EnableEvents = True
End If
End If
End Sub


"RSP" wrote:

I would like to set a field in Excel to be mandatory. I want it to not go to
the next field unless data is entered. O



All times are GMT +1. The time now is 03:16 AM.

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