PDA

View Full Version : Solved: Date Format in UserForm



lhtqasonline
01-22-2009, 04:34 AM
Hi all

I'm using a userform to update existing cells in worksheet.
i have a date textbox and need formatting to apply to it.

Don't know if my question makes sense but here goes:
how do i change the code
Range("A1").NumberFormat = "dd/mm/yyyy"

to work on a textbox called DateContact
something like
Me.DateContact.NumberFormat = "dd/mm/yyyy"

obviously NumberFormat cannot be used with Me.DateContact as it only works when referring to a Range

Newbie

Bob Phillips
01-22-2009, 04:42 AM
DateContact.Text = Format(DateContact.Text, "dd/mm/yyyy")

lhtqasonline
01-22-2009, 04:56 AM
Thank you very much, xld code works now
i still have a bit of stability issues to sort because it sometimes saves as mm/dd/yyyy although the format is now set however if i close the form and open again it shows correctly as dd/mm/yyyy
But it doesn't happen like that every time

Thanks for the assistance

Bob Phillips
01-22-2009, 06:18 AM
Try this amendment



DateContact.Text = Format(CDate(DateContact.Text), "dd/mm/yyyy")

lhtqasonline
01-22-2009, 06:36 AM
That works better, thank you