Insert multiple rown at each change in data

lewis_green

New Member
Joined
Aug 20, 2007
Messages
10
Hi guys. I'm looking for a way to insert 5 blank rows between each change in data in Column B of my spreadsheet.

Currently I am using the following formula which inserts one row, but I have found nothing anywhere for a code that enters more than one row.


Sub MacroChangeindata()
'
' MacroChangeindata Macro
'
'Sub InsertRowAtChangeInValue()
Dim lRow As Long
For lRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(lRow, "A") <> Cells(lRow - 1, "A") Then Rows(lRow).EntireRow.Insert

Next lRow
End Sub

Any help would be appreciated!

Thanks
Lewis
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi. Try this

Rich (BB code):
Sub MacroChangeindata()
'
' MacroChangeindata Macro
'
'Sub InsertRowAtChangeInValue()
Dim lRow As Long
For lRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(lRow, "A") <> Cells(lRow - 1, "A") Then Rows(lRow).Resize(5).Insert

Next lRow
End Sub
 
Upvote 0

Forum statistics

Threads
1,217,473
Messages
6,136,856
Members
450,027
Latest member
Apexwolf

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