Date Problem

LSM1604

New Member
Joined
Jan 8, 2010
Messages
49
Hello,

I have a form which puts a date into a cell, however I have a slight problem with it...

If the date within the form says 15/08/2010, then 15/08/2010 is displayed in the cell.

However, if the date within the form says 06/08/2010, then 08/06/2010 is displayed in the cell.

Why does the cell display the correct date if it is after the 12th in the month, and the wrong date (back to front) if it is the before the 13th of the month?? This doesn't make sense to me?

Any help would be much appreciated.

LSM1604


Below is a small section of my code:

Code:
    Range("Q5").Select
    With ActiveCell
   .NumberFormat = "dd/mm/yyyy"
   .Value = TextBox_DateHidden.Value
    End With
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Do it like this:

.Value = DateValue(TextBox_DateHidden.Value)

VBA is US-centric when it comes to dates, unless the day and month aren't ambiguous. The DateValue function is locale aware.
 

Watch MrExcel Video

Forum statistics

Threads
1,132,869
Messages
5,655,705
Members
418,230
Latest member
Jimmy_Jef

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top