Vba excel - converting Number to Date

  • Thread starter Thread starter ajliaks
  • Start date Start date
A

ajliaks

Hi all,

I have a list of numbers, and I need to sort them as date. fo
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, bu
getting errors in the translation, for example, if I try

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

Could anybody help, please?
Thanks in advance,
Aldo
 
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")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top