Vba Code For Rows Inserton
Vba Code For Rows Inserton
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
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.
Sub InsertRowsAtIntervals()
'Updateby20150707
xTitleId = "KutoolsforExcel"
xRowsCount = WorkRng.Rows.Count
Application.Selection.EntireRow.Insert
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
1. Select the data range that you want to insert blank rows at intervals.
2. Click Kutools > Insert > Insert Blank Rows & Columns, see screenshot: