View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Vba excel - converting Number to Date

Dim NewDate as Date
Dim cell as Range, sStr as String

set cell = ActiveCell
NewDate = cDate(Mid(cell,3,2) & "\" & Left(cell,2) & "\" & Right(cell,2))
sStr = format(NewDate,"dd/mmmm/yyyy")
--
Regards,
Tom Ogilvy


"ajliaks" wrote in message
...

Hi all,

I have a list of numbers, and I need to sort them as date. for
example:

281100 == must be 28/november/2000
110303 == must be 11/march/2003
271004 == must be 27/october/2004

I am trying to convert these numbers into dates, and sorting them, but
getting errors in the translation, for example, if I try

NewDate=CDate(110303), I get 30/December/2201 instead of
11/November/2003

Could anybody help, please?
Thanks in advance,
Aldo.


--
ajliaks
------------------------------------------------------------------------
ajliaks's Profile:

http://www.excelforum.com/member.php...fo&userid=8196
View this thread: http://www.excelforum.com/showthread...hreadid=272786