Excel: Sample Macro to Insert Multiple Rows

Microsoft Excel hosts a number of features that enables users to create worksheets completely tailored to their needs. Among these functionalities is the ability to create a macro, which allows users to make calculations and data manipulations without going through repetitive motions.

Insert Multiple Rows into Excel Worksheet

Excel Task

The below tip will enable you to insert multiple rows between existing rows in an Excel spreadsheet. This macro will enable you to insert a set amount of blank rows into your spreadsheet, and can be modified according to your needs.

Before Macro:

After Macro:





Sample Macro

Here is the macro code needed to perform the above task:
Sub test()    
Dim j As Long, r As Range
j = InputBox("type the number of rows to be insered")
Set r = Range("A2")
Range(r.Offset(1, 0), r.Offset(j, 0)).EntireRow.Insert
Set r = Cells(r.Row + j + 1, 1)
MsgBox r.Address
If r.Offset(1, 0) = "" Then Exit Do

End Sub
Published by aakai1056. Latest update on November 6, 2015 at 08:26 AM by ChristinaCCM.
This document, titled "Excel: Sample Macro to Insert Multiple Rows," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).
Excel - Copy and paste values from specific columns
Excel - A formula to count a list of names