View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Textbox validation

Assuming the textboxes are named txtStartDate and txtEndDate and you need
this validation to happen at CommandButton1 click

Private Sub CommandButton1_Click()

If IsDate(txtStartDate) = False Or IsDate(txtEndDate) = False Then
MsgBox "Invalid Date range"
txtStartDate.SetFocus: Exit Sub
ElseIf CDate(txtEndDate) <= CDate(txtStartDate) Then
MsgBox "End Date should be greater then Start date"
txtEndDate.SetFocus: Exit Sub
ElseIf Format(CDate(txtEndDate), "mmyyyy") < _
Format(CDate(txtStartDate), "mmyyyy") Then
MsgBox "Both dates should be of the same month"
txtEndDate.SetFocus: Exit Sub
End If

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"TUNGANA KURMA RAJU" wrote:

how to Validate a TextBox entry with 3 conditions in Userform?
Textbox2 entry must be a date,that date must be of current month & current
year and it should be greater than TextBox1 date.