adding rows after repeated cells

  • Thread starter Thread starter James
  • Start date Start date
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.
 
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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top