View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
TC[_6_] TC[_6_] is offline
external usenet poster
 
Posts: 10
Default textbox validation

I'm trying to validate user input in a userform textbox, based on a
value in a worksheet cell.
The following sub works fine:

Private Sub TextBoxDay_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBoxDay.Value 0 AND < 32 Then Exit Sub
MsgBox "Valid Days Only"
TextBoxDay = vbNullString
Cancel = True 'Keeps focus until value is null or correct
End Sub


However I cannot get the following code to work:

Private Sub TextBoxDay_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TextBoxDay.Value 0 AND TextBoxDay.Value < _
Worksheets("Begin").Cells(15, 9) Then Exit Sub
MsgBox "Valid Days Only"
TextBoxDay = vbNullString
Cancel = True 'Keeps focus until value is null or correct
End Sub


I've tried a number of variations but I can't seem to find a cell
reference that works. Worksheets("Begin").Cells(15, 9) = 32.

Thanks for any suggestions

Tim