Bossie
New Member
When I convert a string to a date (European format dd/mm/yyyy) using VBA, something strange happens when I put the date in a cell in Excel.
A date like 26/02/2014 (which is february 26 2014) is stored as "general" (and alignes to the left of the cell);
a date like 09/01/2014 (which is september 1 2014) is stored as "date" (and alignes to the right of the cell).
Nevertheless, Excel does recognize the value (stored as general) as a date, because when I subtract one from the other (date - general or general -date) Excel does give the right answer.
I first tried Cdate (which gave me the "American" date") and now I use format(datestr,"dd/mm/yyyy") which does give the right date. It's only when I store it in a cell, it acts weird and chooses "standard" or "date" as cell format.
I did search other forums and the best answer i got was that this seems to be a bug in Excel.
But maybe someone here can help me?
A date like 26/02/2014 (which is february 26 2014) is stored as "general" (and alignes to the left of the cell);
a date like 09/01/2014 (which is september 1 2014) is stored as "date" (and alignes to the right of the cell).
Nevertheless, Excel does recognize the value (stored as general) as a date, because when I subtract one from the other (date - general or general -date) Excel does give the right answer.
I first tried Cdate (which gave me the "American" date") and now I use format(datestr,"dd/mm/yyyy") which does give the right date. It's only when I store it in a cell, it acts weird and chooses "standard" or "date" as cell format.
I did search other forums and the best answer i got was that this seems to be a bug in Excel.
But maybe someone here can help me?