insert blank line at change of year
this assumes all dates are in Column 1
Sub EmptyRow()
Dim cou As Integer, MPStr As String, MPString As String
For cou = 1 To ActiveSheet.UsedRange.Rows.Count - 1
MPStr = Format(ActiveSheet.Cells(cou, 1), "YY")
MPString = Format(ActiveSheet.Cells(cou + 1, 1), "YY")
If Not Val(MPString) = Val(MPStr) Then
ActiveSheet.Rows(Trim(Str((cou + 1)))).Insert
cou = cou + 1
End If
Next
End Sub
--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?
"BillyRogers" wrote:
I have a spreadsheet with a column of sorted dates like this
27-Feb-01
27-Feb-01
01-Feb-02
01-Feb-02
01-Feb-02
I would like a macro that can insert a row at each change of year. Does
anyone have any ideas how to do this?
|