Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

https://webcache.googleusercontent.com/search?

q=cache:W8wkWbrZ4tgJ:https://www.extendoffice.com/documents/excel/2993-excel-
insert-rows-at-intervals.html+&cd=10&hl=en&ct=clnk&gl=in

The following VBA code can help you to insert a specific number of rows after every nth row
within existing data. Please do as follows:

1. Hold down the ALT + F11 keys in Excel, and it opens the Microsoft Visual Basic for
Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Insert specific number of rows into data at fixed intervals

Sub InsertRowsAtIntervals()
'Updateby20150707
Dim Rng As Range
Dim xInterval As Integer
Dim xRows As Integer
Dim xRowsCount As Integer
Dim xNum1 As Integer
Dim xNum2 As Integer
Dim WorkRng As Range
Dim xWs As Worksheet
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address,
Type:=8)
xRowsCount = WorkRng.Rows.Count
xInterval = Application.InputBox("Enter row interval. ", xTitleId, 1, Type:=1)
xRows = Application.InputBox("How many rows to insert at each interval? ",
xTitleId, 1, Type:=1)
xNum1 = WorkRng.Row + xInterval
xNum2 = xRows + xInterval
Set xWs = WorkRng.Parent
For i = 1 To Int(xRowsCount / xInterval)
xWs.Range(xWs.Cells(xNum1, WorkRng.Column), xWs.Cells(xNum1 + xRows - 1,
WorkRng.Column)).Select
Application.Selection.EntireRow.Insert
xNum1 = xNum1 + xNum2
Next
End Sub

 How To Insert Specific Number Of Rows At Fixed


Intervals In Excel?
In Excel worksheet, you can insert a blank row between existing rows by using Insert
function. But, if you have a large range of data, and, you need to insert two blank rows
after every third rows, how could you finish this job quickly and conveniently?
Insert specific number of rows into data at fixed intervals with VBA code

Insert specific number of rows into data at fixed intervals with Kutools for Excel

 Insert Specific Number Of Rows Into Data At Fixed Intervals With VBA Code

Amazing! Using Efficient Tabs In Excel Like Chrome, Firefox And Safari!
Save 50% Of Your Time, And Reduce Thousands Of Mouse Clicks For You Every
Day!

The following VBA code can help you to insert a specific number of rows after every
nth row within existing data. Please do as follows:

1. Hold down the ALT + F11 keys in Excel, and it opens the Microsoft Visual Basic
for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.


VBA code: Insert specific number of rows into data at fixed intervals

Sub InsertRowsAtIntervals()

'Updateby20150707

Dim Rng As Range

Dim xInterval As Integer

Dim xRows As Integer

Dim xRowsCount As Integer

Dim xNum1 As Integer

Dim xNum2 As Integer

Dim WorkRng As Range

Dim xWs As Worksheet

xTitleId = "KutoolsforExcel"

Set WorkRng = Application.Selection

Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)

xRowsCount = WorkRng.Rows.Count

xInterval = Application.InputBox("Enter row interval. ", xTitleId, 1, Type:=1)

xRows = Application.InputBox("How many rows to insert at each interval? ", xTitleId,

xNum1 = WorkRng.Row + xInterval

xNum2 = xRows + xInterval

Set xWs = WorkRng.Parent

For i = 1 To Int(xRowsCount / xInterval)

    xWs.Range(xWs.Cells(xNum1, WorkRng.Column), xWs.Cells(xNum1 + xRows - 1, WorkRng.

    Application.Selection.EntireRow.Insert

    xNum1 = xNum1 + xNum2

Next

End Sub

3. After pasting this code, please press F5 key to run this code, a prompt box will pop
out to remain you selecting the data range that you want to insert blank row, see
screenshot:
4. Click OK button, another prompt box will pop out, please enter the number of row
intervals, see screenshot:

5. Go on clicking OK button, in the following popped out prompt box, please enter the
number of blank rows that you want to insert, see screenshot:

6. Then click OK, and the blank rows have been inserted into the existing data at a
regular intervals, see screenshot:
 Insert Specific Number Of Rows Into Data At Fixed Intervals With Kutools For
Excel

If you are not familiar with above VBA code, Kutools for Excel also may help you, its
Insert Blank Rows & Columns feature can insert specific number of rows or columns
into existing data at fixed intervals quickly and easily.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no
limitation in 60 days. 

Go to Download
Free Trial 60 daysPurchase
PayPal / MyCommerce

After installing Kutools for Excel, please do as follows:

1. Select the data range that you want to insert blank rows at intervals.
2. Click Kutools > Insert > Insert Blank Rows & Columns, see screenshot:

3. In the Insert Blank Row & Columns dialog box, choose Blank rows or Blank


columns you need, from the Insert type, and then specify the number of interval and
blank rows that you want to use as following screenshot shown:
4. Then click OK button, and the blank rows have been inserted into the selected
range at a specific interval as following screenshot shown:

You might also like