View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Macro Date Manipulation

Yes it will, but if you have some rule to apply, it can be adjusted.

What months will be 2005 and the rest 2006?

Is it based on the current month?



Let's assume that months 01 and 02 are in 2006

Sub Convert_to_Date()
for each cell in selection
if clng(Left(cell,2)) 2 then
cell.Value = DateValue(left(cell,2) & "/" & mid(cell,3,2) & _
"/2005")
else
cell.Value = DateValue(left(cell,2) & "/" & mid(cell,3,2) & _
"/2006")
end if
cell.Numberformat = "mm/dd/yyyy"
Next
End Sub

--
Regards,
Tom Ogilvy


"DKY" wrote in message
...

When I click in the cell, I get this
0224
and that code you posted works great! One more problem, what if I have
something like this?
1120
It should be 2005 but with your code, it will make it 2006, right?


--
DKY
------------------------------------------------------------------------
DKY's Profile:

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