View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default String converted to date

Tony

try:

Range("A2").Text = Range("A1").Text

Regards

Trevor


"Tony" wrote in message
...
I have the string '1/1/05 in cell A1. When I execute the following code:

Range("A2").Value = Range("A1").Value

VBA converts the string to a date (i.e., number), which is not what I
want.

I've tried

Range("A2").Value = Cstr(Range("A1").Value)

and even passing the value through a string variable, but the result is
the
same. If the string is _1/1/05, then there is no problem. Ideally, I'd
like
the contents of A1 to be a date and have it converted to a string when
placed
in A2, but that seems too much to ask if I can't even copy a string from
A1
to A2. Help appreciated.

Using Excel 97

Tony