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


It's the darned string comparison issue again:

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

The textbox.value property is a string value. Apparently excel looke
at the Cells().Value property and assumed it was also text.

You may want to do some preliminary checking to make sure the entere
value is numeric before running the compare or it will bomb if an alph
is entered.



--
kkkni
-----------------------------------------------------------------------
kkknie's Profile: http://www.excelforum.com/member.php...nfo&userid=754
View this thread: http://www.excelforum.com/showthread.php?threadid=26871