Excel/VBA - incorrect interpretation of a date

  Heefie 12:20 01 Jan 05

In an Excel spreadsheet, I can enter DD/MM manually and I get Month DD, YYYY displayed in the Cell.

However, when I put this exact same DD/MM date into the Cell via a VBA macro, I still get the output displaying as Month DD, YYYY , but it has been interpreted, incorrectly, as MM/DD, not as DD/MM !!!

For example, I enter 01/02 into the Cell & press Enter ... I get the result February 1, 2005 displayed in the Cell.

I now run my VBA macro :

MyDSRec is defined as STRING and is a line read from a TXT document.

It's value is "NELSON3 17/11 25/11 25/11 01/02"

The command "ActiveCell = Right$(MyDSRec, 5)" successfully places "01/02" into the Active Cell, but it dispays in the Cell as January 2, 2005 ...

How do I correct the Formatting so that this displays correctly ?!?!

  VoG II 20:51 05 Jan 05

I've put your "NELSON3 17/11 25/11 25/11 01/02" into B2 for reference.

The folowing then does what you want:

ActiveCell.Value = Format(Right(Range("B2"), 5), "MMMM d, yyyy")

  VoG II 20:59 05 Jan 05

ActiveCell.Value = Format(Right(Range("B2"), 5), "MMMM d ,yyyy")

  Heefie 06:45 08 Jan 05

Somebody else had given me a way around it, but as usual you come up with a more efficient solution ... thanks ...

This thread is now locked and can not be replied to.

Nintendo Switch (Nintendo NX) release date, price, specs and preview trailer: Codename NX console…

1995-2015: How technology has changed the world in 20 years

8 things designers (and brands) need to know about the modern woman

How to speed up a slow Mac: 19 great tips to make an iMac, MacBook or Mac mini run faster | Speed…