Share via

macro to insert copied row

Anonymous
2010-07-26T17:16:54+00:00

I want to copy a referenced row (which is static) into a variable row (which is incrementally growing as projects are added to the workbook.  suggestions?  below is what I tried (after some other attempts) and cannot get it to work:

    Range("row_copy").Select {this is set, at Rows ("10:10")}

    Application.CutCopyMode = False

    Selection.Copy

    ActiveWorkbook.Rows(Range("row_insert").Value).Select

    Selection.PasteSpecial Paste:=xlPasteFormulas,   Operation:=xlNone, _

    SkipBlanks:=False, Transpose:=False

    Application.CutCopyMode = False

{"row_insert" is a named cell with variable text in the format "17:17", and as projects get added, the numbers incrementally increase}

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

21 answers

Sort by: Most helpful
  1. Anonymous
    2010-07-26T17:45:52+00:00

    I'm afraid I don't quite follow.  Below is a simple copy of the formulas in row 10 into row 11 (static).  What I want to do is to simply allow the row where the formulas are pasted to be dynamic (based on an index which increases every time a new project worksheet gets added to the workbook)

        Rows("10:10")

        Application.CutCopyMode = False

        Selection.Copy

        Rows("11:11")

        Selection.PasteSpecial Paste:=xlPasteFormulas,   Operation:=xlNone, _

        SkipBlanks:=False, Transpose:=False

        Application.CutCopyMode = False

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-07-26T17:40:19+00:00

    Is there any reason why you're selecting the rows before copying and pasting them?  That adds unnecessary run time to your code.  And by "insert" do you mean you actually want to insert copied cells?  Because what you're doing is pasting over data that would already be in "row_insert."  And if you don't need to insert new rows, then you're not really "inserting" copied data, you're just pasting it into a new location.

    As Rick said, you need to specify how "row_insert" is variable.  Is it at the end of your data set?  Is it always after a cell with a certain value?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-07-26T17:38:05+00:00

    I meant "Project 2" not 12

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-07-26T17:37:03+00:00

    the 'copy row' is set at row 10; when the macro runs, a new project worksheet ("Project 1") is created by copying a project template worksheet. the copy row references data from the 'Project Template' worksheet, row 11 becomes the row for "Project 1", and what I want to do is copy row 10 into row 11 (I am usingINDIRECT to reference named variables in each project worksheet); then when the next project, Project 12, is created I want to copy row 10 into row 12, and so on

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2010-07-26T17:23:14+00:00

    How is this "variable row" determined? Is it the first blank row after the last piece of data? A selected row (where you would insert a blank row that the copy would go to)? Something else?

    Was this answer helpful?

    0 comments No comments