View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Medemper Medemper is offline
external usenet poster
 
Posts: 26
Default Printing Excel Dates (Format dd/mm/yy)

Could you do PostingDate.NumberFormat="dd/mm/yy" after PostingDate =
..Cells(RSRow, 5)?

"john pritchard" wrote in message
...
Hi,

All I really want to do is read a cell and write its
contents. The contents happen to be a date in UK format
i.e. 31/07/03 means March 31 2003 and 01/08/03 means
August 1 2003. Originally I simply had:-

PostingDate = .Cells(RSRow, 5)

in the appropriate with structure etc with postingdate
defined as a string. Later this was written to another
sheet with :-

Cells(LSRow, 18) = PostingDate


which writes 31/07/03 as expected when that is what is
read BUT 37629 when 01/08/03 is read. I've tried
reformating the Cells in the code with :-

.Cells(RSRow, 5).NumberFormat = "dd/mm/yy"

PostingDate = .Cells(RSRow, 5)

and converting to text with :-

.Cells(RSRow, 5).NumberFormat = "@"

I've also tried using datepart but if I do that 31/07/03
results in year 1931 while 01/08/03 gets 2003. The macro /
VB code is distributed to many PC's and I have no control
over the PC's settings.

The original input file is created with Crystal Reports (I
have no control here either) and the relevant cell is
General format to start with.

As you can imagine inability to read/write 01/08/03 is
embarassing to say the least!

Thanks for any suggestions

JP