Excel 2003 vba date format

User avatar
Bigger312
StarLounger
Posts: 51
Joined: 12 Mar 2012, 16:42
Location: Dublin, Ireland

Excel 2003 vba date format

Post by Bigger312 »

Hi,
I have a sheet named dashboard where cells C4 to i4 have a date value in the format "30th April 2012" this data is then transfered to a userform named "dashboard" to textbox named "Tx1" to "Tx7". The date format changes on the userform to USA date format i.e. 4/30/2012. I have tried to use CDate(Me.tx1.Value) = Range("DashBoard!C4").Value but I get a syntax error.

Thanks again for your help and time.

Gerry

Code: Select all


'    
    Me.Tx1.Value = Range("DashBoard!C4").Value
    Me.Tx2.Value = Range("DashBoard!D4").Value
    Me.Tx3.Value = Range("DashBoard!E4").Value
    Me.Tx4.Value = Range("DashBoard!F4").Value
    Me.Tx5.Value = Range("DashBoard!G4").Value
    Me.Tx6.Value = Range("DashBoard!H4").Value
    Me.Tx7.Value = Range("DashBoard!i4").Value

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Excel 2003 vba date format

Post by HansV »

You can use

Me.Tx1.Value = Range("DashBoard!C4").Text

to populate the text box with the value of the cell as displayed on the screen.
Best wishes,
Hans

User avatar
Bigger312
StarLounger
Posts: 51
Joined: 12 Mar 2012, 16:42
Location: Dublin, Ireland

Re: Excel 2003 vba date format

Post by Bigger312 »

:hailpraise:

Thanks Hans . Works perfectly.



Gerry