Thread: Date conversion
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
fazstp[_12_] fazstp[_12_] is offline
external usenet poster
 
Posts: 1
Default Date conversion


This will format dates in column A from row 2 down.

Sub FormatDates()
Dim RowNum As Integer
Dim NextValue As String
Dim NextDate As Date

For RowNum = 2 To Range("A1").CurrentRegion.Rows.Count
NextValue = Range("A" & RowNum).Value
NextDate = DateSerial(2000 + Mid(NextValue, 1, 1),
Mid(NextValue, 2, 2), Mid(NextValue, 4, 2))
Range("A" & RowNum).NumberFormat = "dd/mm/yyyy"
Range("A" & RowNum).Value = NextDate
Next RowNum
End Sub

Personally I find excel's handling of dates to be eratic at best. Even
when I force the dates into a format I want, if I copy the sheet to
another workbook the formats are totally screwed up. Then if you try to
format the column post-copy it just doesn't work.


--
fazstp
------------------------------------------------------------------------
fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574
View this thread: http://www.excelforum.com/showthread...hreadid=548400