View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Date formatting in Excel VBA Text Box

Private Sub TextBox1_Exit()
With TextBox1
If Not IsDate(.Text) Then
MsgBox ("Invalid date")
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"TimN" wrote in message
...
Hi all,

I am new to VBA programming so forgive me for an elementary question, but

I
can't seem to locate the answer.

I have created a User Form so that a date is entered then that date is
placed in a cell on the Excel spreadsheet. I want to format the Text Box

to
only accept a valid date format such ad 01/10/06. How do I do that?

Thanks
TimN