ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text Validation (https://www.excelbanter.com/excel-programming/321074-text-validation.html)

Paul K.

Text Validation
 
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 K.

Text Validation
 
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

"Charles Harmon" wrote:

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

"Paul K." <Paul wrote in message
...
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





Charles Harmon

Text Validation
 
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.
"Paul K." wrote in message
...
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

"Charles Harmon" wrote:

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

"Paul K." <Paul wrote in message
...
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








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

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