Macro to Insert Rows in Excel


Insert a row (one row each) in between each row containing data


Sub InsertRows()
Range("A2").Select
Do Until ActiveCell.Value = ""
Selection.EntireRow.Insert
ActiveCell.Offset(2, 0).Select
Loop
End Sub

Insert 2 Rows in between each row containing data


Sub Insert2Rows()
Range("A2").Select
Do Until ActiveCell.Value = ""
Selection.EntireRow.Insert
Selection.EntireRow.Insert
ActiveCell.Offset(3, 0).Select
Loop
End Sub

Insert Rows in between each row containing data, based on user Input


Sub InsertNRows()
Range("A2").Select
Dim d, e As Integer
e = Val(InputBox("Enter the number of Rows to be inserted"))
Do Until ActiveCell.Value = “”
For d = 1 To e
Selection.EntireRow.Insert
Next d
ActiveCell.Offset(e + 1, 0).Select
Loop
End Sub

How to use codes shared here?