The following macro will fill down dates in col I starting with the last date entered to the end of that month. But I have to change the number of days manually from 31 to 30, 28, etc. How can this macro be edited to always fill to the last day any given month.
LastDate = DateValue("31/" & Month(.Value) & "/" & Year(.Value)) - .Value
Original post was: http://www.excelforum.com/excel-programming/668430-macro-to-auto-fill-dates-in-column.html
LastDate = DateValue("31/" & Month(.Value) & "/" & Year(.Value)) - .Value
Code:
Dim LastRow As Long
Dim LastDate As Long
LastRow = Cells(Rows.Count, "I").End(xlUp).Row
With Cells(LastRow, "I")
LastDate = DateValue("31/" & Month(.Value) & "/" & Year(.Value)) - .Value
On Error Resume Next
.AutoFill Destination:=Range("I" & LastRow & " :I" & LastRow + LastDate), Type:=xlFillDefault
End With
Original post was: http://www.excelforum.com/excel-programming/668430-macro-to-auto-fill-dates-in-column.html