Inserting Rows with Input Box selection

rubic

Active Member
Joined
Jul 9, 2008
Messages
251
Hi,

Earlier today I posted a question on deleting empty rows within the selection via an input box and thankfully I got the answer I want within a very short time.
Now the question I have is, instead of deleting of empty rows, I want to insert blank row or rows via an input boxes selection. What the macro need to do is is ask for the range to insert the empty row and after selection of the range via the input box will then ask for the number of rows to insert within the selected range.
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

northwolves

Well-known Member
Joined
Jun 21, 2006
Messages
1,122
Try:
Code:
Sub Macro1()
Dim msg As String
msg = InputBox("Please enter the range and rows count to insert rows", "Info", "A7 12")
Range(Split(msg)(0)).Resize(Split(msg)(1), 256).Insert Shift:=xlDown
End Sub

Regards
Northwolves
 

rubic

Active Member
Joined
Jul 9, 2008
Messages
251
Northwolves,

Thanks for the quick reply. I ran the macro and this is what I encountered. The input box did not allow me to use the mouse to select a range. I then manually key in the range I wanted to insert, I encountered some form of error message.
I wonder do the codes allows to input the number of rows to insert?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,577
Messages
5,596,996
Members
414,116
Latest member
sfullnet

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
Top