Hi all, looking for a little help on a code below. Thanks in advance!
The code below allows me to insert X number of rows when I have selected a given row. So, if I select row 3 and ask it to insert 2 rows on a popup, it inserts those 2 rows.
What I would like it to do is insert X rows after every row I select simultaneously. So, if I hold CTRL and select rows 3, 7, and 12 I would want it to add X rows after each of those rows.
I hope that's a small edit here. Thanks for your help!
Sub InsertRows()
Dim numRows As Variant
Dim i As Long
numRows = InputBox("Insert Number of Rows", "Insert Rows")
If numRows = "" Then Exit Sub
If Not IsNumeric(numRows) Then Exit Sub
For i = Selection.Rows.Count To 1 Step -1
Selection.Rows(i).Resize(numRows).Insert
Next i
End Sub
The code below allows me to insert X number of rows when I have selected a given row. So, if I select row 3 and ask it to insert 2 rows on a popup, it inserts those 2 rows.
What I would like it to do is insert X rows after every row I select simultaneously. So, if I hold CTRL and select rows 3, 7, and 12 I would want it to add X rows after each of those rows.
I hope that's a small edit here. Thanks for your help!
Sub InsertRows()
Dim numRows As Variant
Dim i As Long
numRows = InputBox("Insert Number of Rows", "Insert Rows")
If numRows = "" Then Exit Sub
If Not IsNumeric(numRows) Then Exit Sub
For i = Selection.Rows.Count To 1 Step -1
Selection.Rows(i).Resize(numRows).Insert
Next i
End Sub