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.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

northwolves

Well-known Member
Joined
Jun 21, 2006
Messages
1,128
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
  5. 2010
  6. 2007
  7. 2003 or older
Platform
  1. Windows
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?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,517
Messages
5,832,225
Members
430,117
Latest member
RRattle

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