Insert Multiple Rows - Popup Box VBA

bmkelly

Board Regular
Joined
Mar 26, 2020
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am looking for a macro that can insert 'x' amount of rows at ActiveCell that will give the user a pop box to enter however many rows they need to insert.

I am currently using this formula

Sub InsertRow()
ActiveCell.EntireRow.Resize(1473).Insert Shift:=xlDown
End Sub


The formula above works fine but would love to make it that much easier for users to have a pop up box appear so they can just insert in 'x' amount of rows instead of going into the Macro and changing the resize number (Example of above they would have to change the 1473 number every time they want to insert)

Thanks!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Try this:
VBA Code:
Sub InsertRow()
    
    Dim i As Integer
    
    On Error GoTo err_check
    i = InputBox("How many rows would you like to insert?")

    ActiveCell.EntireRow.Resize(i).Insert Shift:=xlDown
    
    Exit Sub
    
err_check:
    MsgBox "You must enter a valid number of rows to insert!", vbOKOnly, "ENTRY ERROR!"
    
End Sub
 
Upvote 0
How about
VBA Code:
Sub bmkelly()
   Dim Rws As Variant
   
   Rws = InputBox("How many rows")
   If Rws = "" Then Exit Sub
   ActiveCell.EntireRow.Resize(Rws).Insert
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,829
Messages
6,181,218
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top