Text>Date ???

S

silentpro

I have a workbook that has multiple sheets & each one has a date field.
Someone entered the dates in a non xl date format

Example: January 6 2009

I tried formatting the whole column to show d/m/yy but the text example
above doesn't format.

Is there a macro or something that I can run to convert these text dates to
an actual date format?


Thanks
 
R

Rick Rothstein

I think this macro will do what you want (just change the sheet name and
cell range in the For Each statement to match your actual conditions)...

Sub MakeNearDatesRealDates()
Dim C As Range
For Each C In Worksheets("Sheet1").Range("C:C")
If TypeName(C.Value) <> "Date" Then
If IsDate(C.Value) Then C.Value = CDate(C.Value)
End If
Next
End Sub
 
S

silentpro

Perfect, thank you very much!!!!


Rick Rothstein said:
I think this macro will do what you want (just change the sheet name and
cell range in the For Each statement to match your actual conditions)...

Sub MakeNearDatesRealDates()
Dim C As Range
For Each C In Worksheets("Sheet1").Range("C:C")
If TypeName(C.Value) <> "Date" Then
If IsDate(C.Value) Then C.Value = CDate(C.Value)
End If
Next
End Sub
 

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

Top