PDA

View Full Version : Date format problem



sujittalukde
01-10-2008, 06:11 AM
I am transferring dates to a column in a new excel workbook through macro ie I am inputting data in an excel sheet then generating a report in a new excel workbook.
In the excel sheet where data is entered, there is a column where dates are to be entered in dd/mm/yyyy format. The macro takes date from this column to a cell in the new workbook that it creates. Here the problem is coming.
The date in the cell to the new workbook, though comes in dd/mm/yyyy format but excel is recognizing the same as mm/dd/yyyy ie 10/01/2008 is transferred as 10/01/2008 but the excel in new workbook is recognizing the same as 10th October 2008.

My regional settings are set as dd/mm/yyyy format.The column format, in macro code number format "dd/mm/yyyy" is used.

In case date are entered directly, then the excel is recognizing the date as dd/mm/yyyy but via macro when the date is transferred it is recognizing as mm/dd/yyyy format In the code the number format "dd/mm/yyyy" is also used but not yielding the correct result.

How can I correct this?

White_Nova
01-10-2008, 06:48 AM
hi there

Have you tried using the text to coloumbs option in your macro???
Run it as a macro and you can specify the format you want the order to be in...

Bob Phillips
01-10-2008, 07:03 AM
Cast the date



wb2.Worksheets(1).Range("A1").Value = CDate(wb1.Worksheets(1).Range("H1").value)