Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
need help with macro to convert number to date
I did a search on this site and found a macro to convert a number to a
date. So i tried to update it to match my situation. However, I get a runtime error 13 type mismatch. I have a column of birthdates that come across as 20050102 and I need it to read 01/02/2005. This is the macro: Sub makedate() Dim NewDate As Date Dim cell As Range, sStr As String Set cell = Range("a:a") NewDate = CDate(Mid(cell, 3, 2) & "/" & Left(cell, 2) & "/" & Right(cell, 2)) sStr = Format(NewDate, "dd/mm/yyyy") End Sub This is the line that is giving the run time error: NewDate = CDate(Mid(cell, 3, 2) & "/" & Left(cell, 2) & "/" & Right(cell, 2)) Does anyone have an idea of why? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Convert number to date value | Excel Discussion (Misc queries) | |||
Convert number to date | Excel Discussion (Misc queries) | |||
Convert Date to number | Excel Programming | |||
Convert a number formatted as text to a number in a macro | Excel Programming | |||
How do I convert Date serial number to date | Excel Worksheet Functions |