Copy Selected Rows & Insert As Many Times As Rows Selected

  • Hi,

    The following code inserts a row below the selected row, and copies the formula of the row above into it.

    Dim Rw as Integer
    Rw = ActiveCell.Row
    Selection.Insert Shift:=xlDown
    Rows("" & Rw - 1 & ":" & Rw - 1 & "").Copy
    Rows("" & Rw & ":" & Rw & "").Paste

    However, I need to alter this to work for inserting more than one row at a time.
    ie. the user selects 'x' number of rows and 'x' rows are inserted below (in the same way 'Insert Row' works in Excel) and the row above the selection is copied down.

    I can't figure out how to do it. Is this possible?


  • Re: Select A Range Of Rows And Copy

        Rows(Selection.Row + Selection.Rows.Count).Insert Shift:=xlDown
        Application.CutCopyMode = False

    [FONT="Arial Black"][COLOR="blue"][SIZE="4"]Bill[/SIZE][/COLOR][/FONT]
    Tip: To avoid chasing code always use Option Explicit.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!