How do I create a mandatory field in Excel

G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top