adding rows after repeated cells

J

James

I would like to add a blank row after repeated cells. For example I would have
12
12
12
9
7
7
2
2
2
But I would like to have something like this
12
12
12

9

7
7

2
2
2
I have on the range of about 12,000 rows and I do not want to do this
manually because I would be afraid if missed something. Thanks for the help.
 
J

Joel

Try this macro

Sub AddBlankRows()

RowCount = 1
Do While Range("A" & RowCount) <> ""
If Range("A" & RowCount) <> Range("A" & (RowCount + 1)) Then
Rows(RowCount + 1).Insert
RowCount = RowCount + 2
Else
RowCount = RowCount + 1
End If
Loop
End Sub
 
J

James

Works GREAT!! Thank you

Joel said:
Try this macro

Sub AddBlankRows()

RowCount = 1
Do While Range("A" & RowCount) <> ""
If Range("A" & RowCount) <> Range("A" & (RowCount + 1)) Then
Rows(RowCount + 1).Insert
RowCount = RowCount + 2
Else
RowCount = RowCount + 1
End If
Loop
End Sub
 
G

Gord Dibben

Sub InsertRow_At_Change()
'Sandy Mann July 1st, 2007
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False

For X = LastRow To 3 Step -1
If Cells(X, 1).Value <> Cells(X - 1, 1).Value Then
If Cells(X, 1).Value <> "" Then
If Cells(X - 1, 1).Value <> "" Then
Cells(X, 1).entirerow.Insert Shift:=xlDown
End If
End If
End If
Next X

Application.ScreenUpdating = True
End Sub

Assumes data is in column A


Gord Dibben MS Excel MVP
 
Top