Thread: CDate Problem
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default CDate Problem

Try Datevalue instead of CDate.

HTH. Best wishes Harald

"sil0000" skrev i
melding ...

Hello!
I have a problem converting string to date.

Working with Excel 2003, function Cdate works fine. If I do

Range(myCell).Value = CDate("22/02/2005")

in the cell is shown 22/02/2005 (My regional configuration is
dd/mm/yyyy).

But if I use this program with Excel XP, the function doesn't work
correctly because it tries to make a date which is the day 2 of the
month 22.
I've tried to do MiDate = CDate(#2/22/2005#) but it doesn't work.

The solution in office XP is:
Range(myCell).NumberFormat = "dd/mm/yyyy"
Range(myCell).Value = "22/02/2005"

But this solution doesn't work in Excel 2003!!!

The problem is that I need a solution working for both versions. Is it
possible to know the version of Excel?

Can anyone help me please???

Thank-you!!!


--
sil0000
------------------------------------------------------------------------
sil0000's Profile:

http://www.excelforum.com/member.php...o&userid=25460
View this thread: http://www.excelforum.com/showthread...hreadid=389020