Monday, June 24, 2019

Macro to insert multiple rows | VBA Code to insert multiple rows


Macro to insert multiple rows | VBA Code to insert 

multiple rows


Open Excel Sheet
Press Alt + F11 Key 
Go to the Insert Menu and Click on new Module
in New Module copy and paste the above VBA code and save.
Now Press Alt + F8  and new windows will open which is shown in below figure,
in that windows you will ask to enter a key to create shortcut for Paste Special
Enter a letter in the box. 

Macro to insert multiple rows | VBA Code to insert multiple rows


Sub InsertMultipleRows()
Dim i As Integer
Dim j As Integer
ActiveCell.EntireRow.Select
On Error GoTo Last
i = InputBox("Enter number of columns to insert", "Insert
Columns")
For j = 1 To i
Selection.Insert Shift:=xlToDown,
CopyOrigin:=xlFormatFromRightorAbove
Next j
Last:Exit Sub
End Sub