PDA

View Full Version : [SOLVED:] Covert text to date



farrukh
12-11-2011, 12:39 PM
Hi All i need a code to run opening of the workbook covert sheet colum A text
201111,201112 etc to date format like nov,2011 and dec,2011.

thanks
hammeed

nilem
12-11-2011, 01:54 PM
try it

Sub ert()
Dim r As Range
For Each r In [A:A].SpecialCells(2)
r = Format(DateSerial(Left(r, 4), Right(r, 2), 1), "mmm,yyyy")
Next
End Sub

farrukh
12-11-2011, 10:39 PM
Hi Nilem ,

I am getting error Object required..

Thanks
hammeed

nilem
12-11-2011, 10:45 PM
can you show your book sample with an error?

farrukh
12-12-2011, 03:09 AM
Hi Nilem,

Thats work great the code was not running because i have the text name DATE in A1, by removing the string Date it is working fine for all the range :)