View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default How can this be???

<kirkm wrote:
I suppose I'm too pratical where 'text' is just
text and you don't anticpate some change
you haven't asked for.


Your comment suggests to me that you did not fully understand the responses.

You don't have text; you have a number. You formatted that number with a
custom date format.

When you do:

..Cells(mL, mC) = mVal

you are assigning only the cell value, the number. You neglected to specify
the format.

If you want to control the format, you also need:

..Cells(mL, mC).NumberFormat= "dd mmm yyyy"

More generally, if mVal is a cell reference (type Range), you can do:

..Cells(mL, mC) = mVal
..Cells(mL, mC).NumberFormat= mVal.NumberFormat


Yes, I corrected it with Format... which was ironic as it
was formtted initially... haha, perhaps it's a reformat :)


Actually, the irony is: it may have worked for you only because you
formatted the cell initially with the desired format.

It is unclear to me what Format() parameters you used. FSt1 had written
"mm/dd/yy". You had written: "Reading the cell magically converts it to
8/03/1980", which suggests that you might used "d/mm/yyyy". On the other
hand, if you wanted the original format, you might used "dd mmm yyyy".

But if Cells(mL,mC) had a General format initially, none of those would
result in their intended format simply by assigning Format() to the cell
value.

The first two formats result in the default Date format, the form of which
varies depending on localization. The last format results in the Custom
format d-mmm-yy (!).

(At least, that is the case for my localization settings. I have not tried
others.)

Cheers!


----- original message -----

<kirkm wrote in message ...
Thanks to you both for answering. At least that number
has a meaning and explanation. I suppose I'm too pratical
where 'text' is just text and you don't anticpate some change
you haven't asked for.

Yes, I corrected it with Format... which was ironic as it
was formtted initially... haha, perhaps it's a reformat :)

Cheers - Kirk