Text Validation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to require a user to enter text into a field (text field)
after data is entered into another field. This isn't a form. Just a regular
Excel worksheet. I thought I could use the text length validation criteria
and uncheck the Ignore Blank option, but no luck. Is this functionality even
possible? Thank you. Paul
 
Paul,
Have you tried a Worksheet_Change Event? You can set it to validate the
range in question.
This is something simple it goes in the sheet code you are working on.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Set rng = Range("A1")
If IsEmpty(rng) Then
MsgBox "HI"
End If

End Sub


Charles
 
This works for one cell. I need to validate text for a range of cells.
Also, if I select OK from the MsgBox and don't enter the data and move on to
another cell and enter data, the MsgBox is displayed again, but my active
cell isn't where the data is required. Is there a way to validate data for a
range as well as place the cursor back to the cell where the text is
required? Thank you for your assistance. Paul
 
Paul,

Try this.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim myarray As Variant
Dim mycnt As Integer
myarray = Array("A1", "B2", "C3")<<<<< You need to add the cells you want to
check
With Worksheets("sheet1")
For mycnt = 1 To UBound(myarray)
If .Range(myarray(mycnt)).Value = "" Then
MsgBox "I'M Sorry missing information : " & myarray(mycnt)
.Range(myarray(mycnt)).Select
Exit Sub
End If
Next
End With
End Sub
Put code in the workbook module.
 

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

Back
Top