Date in text box reading mm/dd/yy instead of dd/mm/yy

M

Maddoktor

Hi all,

I have a userform with a textbox where a user will input the date. As I am
from Australia, the standard format would be dd/mm/yy. This works ok until I
click the OK button and the data is transferred to the worksheet as
mm/dd/yy.

Can someone tell me if I will need to insert a line of coding in the
userform to convert the date to dd/mm/yy and then transferred to the
worksheet as dd/mm/yy instead of mm/dd/yy.

Thanx in advance.
 
N

Nick Hodge

Whilst Excel handles locale quite well, VBA does not so you will have to
coerce it. This worked for me if the cells were pre-formatted as text

Private Sub CommandButton1_Click()
Range("A1").Value = DateValue(Me.TextBox1.Value)
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top