Inserting multiple rows in excel with data in consecutive rows
Hi,
Here is a macro that I wrote several years ago. It inserts x rows between
each row within the selected range:
Public Sub Insert_Rows_betwn_existing()
Dim R As Long
Dim n As Long
Dim Rng As Range
Dim myCell As Range
Dim NumRows As Integer
If Selection.Rows.Count 1 Then
NumRows = InputBox("Enter number of rows to insert between each row
in the selection")
On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set Rng = Selection
n = 0
For R = Rng.Rows.Count To 1 Step -1
Rng.Rows(R + 1).Resize(NumRows).EntireRow.Insert
' MsgBox ("row " & N)
n = n + 1
Next R
MsgBox (n & " groups of " & NumRows & " rows inserted")
Rng.Rows(R + 1).Select
Else
MsgBox ("Must select one or more rows before executing command")
End If
EndMacro:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
No doubt there is a better/cleverer way to do it.
Sean
"technotronic" wrote in message
...
I am using Office 2003. I have data in Column A. However, I would like to
insert x number of rows inbetween each row that has data. The data is
currently in consecutive rows. For example, if I choose to insert three
rows, then three rows should be inserted below each row that has data.
Thereafter, if I need to insert another x number of rows, then these
should
be added below the three rows that were already added. This should apply
to
all the rows that have data. Please assist.
|