Odd date behaviour

CMIIandExcel

Board Regular
Joined
Sep 4, 2009
Messages
190
I have an issue when transfering a date from one spreadsheet to another

A UK format date is being changed to a US format date

The date is passed within a varible declared as :

Dim strExportDate As String

This date is passed ByVal to another Sub routine and then then called and entered into another workbook by;

shExport.Cells(3, 3) = strExportDate

The format of the cell the date is taken from is
DATE UK-Locale *dd/mm/YYYY

The format of the Cell where the date is then entered is
DATE UK-Locale dd/mm/YYYY

(note the *is the only difference)

Somehow the value is being changed from UK to US, eg 04/09/2009 from the source cell is becoming 09/04/2009 in the destination cell

Thanks in advance for any assitance

Mike:confused:
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Are you 100% sure the value is being changed? Perhaps it's just the format.

If strExportDate try converting it to a true date using DateValue.
Code:
shExport.Cells(3, 3) = DateValue(strExportDate)
That should definitely give you a date, but again you might have to check the formatting.:)
 
Upvote 0
Norie

as far as i could see yes the value was being changed, however the DateValue statement worked a treat.

Thank you kindly:)

morals to this story

Simple solutions are the best:eek:
Never test a macro that transfers dates with the date 09/09/09 :p
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,509
Members
448,967
Latest member
screechyboy79

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
Back
Top