Value must be entered

J

JStiehl

Is it possible to require a value to be entered into a cell, and give a
warning if no value is entered? Is it possible to prevent someone who is
entering data in the form from moving to the next cell until this required
data is entered? Thanks for your help.
 
G

Gary''s Student

This is an example using cell B9. Once the cell is selected, a value must be
entered before the user can navigate elsewhere.

Put this event macro in the worksheet code area

Public b9 As Boolean

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set r = Range("B9")
If Intersect(Target, r) Is Nothing Then
If b9 Then
If IsEmpty(r) Then
MsgBox ("B9 must be filled")
r.Select
Else
b9 = False
End If
End If
Else
b9 = True
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