VBA looping, then inserting blank row

PB7

Board Regular
Joined
Mar 1, 2011
Messages
58
Hello VBA colleagues.

I have a spreadsheet sorted by individual people names in column E.

I need VBA to loop through, and insert a blank row, at each change in the names is Column E.

All spreadsheet data goes from column A to Z, for whatever number of rows there are for any given instance.

I've done a lot of surfing in Mr. E and Google, with no luck. Would anyone has something quick for this?

Thanks in advance, for any attention or response to this request.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Code:
Sub Insert_Rows()
    Dim i As Long
    Application.ScreenUpdating = False
    For i = Range("E" & Rows.Count).End(xlUp).Row To 2 Step -1
        If Cells(i, "E") <> vbNullString And Cells(i - 1, "E") <> vbNullString Then
            If Cells(i, "E") <> Cells(i - 1, "E") Then Rows(i).Insert
        End If
    Next i
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
AlphaFrog, the code worked like a champ, & 1st time too! Thank you, thank you, for the great, quick response.
 
Upvote 0
Greetings all,

I was wondering if anyone could provide assistance on a variation of this?

I need a macro that will insert a blank row between my data when it finds a different result in column E (date field), but also if it finds a different result in column B (area code).

Please advise.

Thank you,
limeyadam.
 
Upvote 0
Do you want to insert a blank row when both B and E are different or when B or E are different?
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top