Hi folks,
I am a noob when in comes to macros but I would be grateful for a solution that piggie backs on the macro written below by Leith Ross. I'm looking to write a macro to insert one entire row into a set of data after each data group ends. The macro below only inserts a cell between each data group.
E.g. Column A contains the following data starting with A1, then A2 etc. I also have data in columns B, C, D, E etc... The empty row would move all data in the row down, not just the column A. However, the criteria for the data group will still be column A. Does this make sense?
A1 = BB
A2 = BB
A3 = BB
A4 = CC
A5 = CC
A6 = CC
A7 = DD
A8 = DD
A9 = EE
A10 = EE
I would like to run a macro which will insert one entire row after each similar data sets ends.
The result would be the following
A1 = BB
A2 = BB
A3 = BB
A4 = (EMPTY ROW)
A5 = CC
A6 = CC
A7 = CC
A8 = (EMPTY ROW)
A9 = DD
A10 = DD
A11 = (EMPTY ROW)
A12 = EE
A13 = EE
'Written: Sept. 18, 2007
'Author: Leith Ross
'Summary: Add blank cells where the data changes
Sub AddBlankLines()
Dim Col As Variant
Dim BlankRows As Long
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
Col = "A"
StartRow = 1
BlankRows = 2
LastRow = Cells(Rows.Count, Col).End(xlUp).Row
Application.ScreenUpdating = False
With ActiveSheet
For R = LastRow To StartRow + 1 Step -1
If .Cells(R, Col) <> Cells(R - 1, Col) Then
.Cells(R, Col).Resize(RowSize:=BlankRows).Insert Shift:=xlDown
End If
Next R
End With
Application.ScreenUpdating = True
End Sub
Thanks in advance.
Tom
Bookmarks