Log in

View Full Version : problem with date format when I use userform



007juk
04-02-2008, 02:36 PM
Hi,

I have created a userform which contains text boxes and combo boxes. When I enter a date, e.g. 01/04/08 it populates cell with 04/1/08. If I enter, e.g 25/03/08 it displays OK.

I have tried formating cell, but that doesn't work. I have also checked my regional settings too.

Is it possible to enter, e.g. 010408 in the text box and for it to display 01/04/08 on the sheet.

Thanks.

lucas
04-02-2008, 08:39 PM
This is one way that should work......if your date is coming from the textbox.

Private Sub CommandButton1_Click()
Range("A1").Value = TextBox1.Value
Range("A1").NumberFormat = "mm/dd/yy"
End Sub

mdmackillop
04-03-2008, 11:31 AM
Are you using UK or American date formats on your PC. Userforms by default use US display regardless.

007juk
04-10-2008, 03:01 PM
thanks Lucas, that worked great.

lucas
04-10-2008, 07:54 PM
be sure to mark your thread solved using the thread tools at the top of the page.