Inserting multiple rows between every row of one column/range

MrNotSoExcellent

New Member
Joined
Aug 23, 2023
Messages
1
Office Version
  1. 2016
Platform
  1. MacOS
I'm looking for help to write a code that allows me to insert a certain amount of rows into a specific range of cells. The code I'm using (I found somewhere while scouring the internet) is the following:

VBA Code:
Sub InsertARow()
Dim j As Long
Dim r As Range
j = 5
Set r = Range("A1")
Do While r.Value <> ""
    Set r = r.Offset(1, 0)
    For i = 1 To j
        r.Rows.Insert
    Next
Loop

End Sub

The code works fine when I only need to add say 5 rows but it takes forever to run when I want to insert 60 rows. Does anyone have a solution or just a 'better' code to do this?

Thanks so much!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi & welcome to MrExcel.
How about
VBA Code:
Sub MrNotSo()
   Dim i As Long, j As Long
   
   j = 5
   For i = Range("A" & Rows.Count).End(xlUp).Row To 2 Step -1
      Rows(i + 1).Resize(j).Insert
   Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,131
Messages
6,123,223
Members
449,091
Latest member
jeremy_bp001

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