If you want to format dates like 1st March 2013 , 2nd March 2013 ,etc . Try this macro
Sub fmt_dates()
Dim Cell As Range
Dim fmttext As String
For Each Cell In Selection
Select Case Day(Cell)
Case 1, 21, 31:
fmttext = """st"""
Case 2, 22:
fmttext = """nd"""
Case 3, 23:
fmttext = """rd"""
Case Else:
fmttext = """th"""
End Select
Cell.NumberFormat = "d" & fmttext & ", MMMM YYYY"
Next Cell
End Sub
Sub fmt_dates()
Dim Cell As Range
Dim fmttext As String
For Each Cell In Selection
Select Case Day(Cell)
Case 1, 21, 31:
fmttext = """st"""
Case 2, 22:
fmttext = """nd"""
Case 3, 23:
fmttext = """rd"""
Case Else:
fmttext = """th"""
End Select
Cell.NumberFormat = "d" & fmttext & ", MMMM YYYY"
Next Cell
End Sub
No comments:
Post a Comment