+ Reply to Thread
Results 1 to 3 of 3

Inserting Variable Number of Rows

  1. #1
    Registered User
    Join Date
    05-16-2005
    Posts
    11

    Inserting Variable Number of Rows

    I'm trying to create a chunk of code that copies an entire row and then inserts a variable amount. here is the code

    insertrows = 3 + prodlength
    Rows("3:3").Select
    Selection.Copy
    Rows("4:insertows").Select
    Selection.Insert Shift:=xlDown

    Is it possible to do something like this? I'm trying to do this method because it copying and inserting rows preserves all the formatting. The variable prodlenght is the number of products found off another worksheet in the workbook.

  2. #2
    PY & Associates
    Guest

    RE: Inserting Variable Number of Rows

    Would you consider replacing
    > Rows("4:insertows").Select
    > Selection.Insert Shift:=xlDown


    with
    Rows("4:insertows").entirerow.insert

    "bundyloco" wrote:

    >
    > I'm trying to create a chunk of code that copies an entire row and then
    > inserts a variable amount. here is the code
    >
    > insertrows = 3 + prodlength
    > Rows("3:3").Select
    > Selection.Copy
    > Rows("4:insertows").Select
    > Selection.Insert Shift:=xlDown
    >
    > Is it possible to do something like this? I'm trying to do this method
    > because it copying and inserting rows preserves all the formatting. The
    > variable prodlenght is the number of products found off another
    > worksheet in the workbook.
    >
    >
    > --
    > bundyloco
    > ------------------------------------------------------------------------
    > bundyloco's Profile: http://www.excelforum.com/member.php...o&userid=23386
    > View this thread: http://www.excelforum.com/showthread...hreadid=399996
    >
    >


  3. #3
    Bob Phillips
    Guest

    Re: Inserting Variable Number of Rows

    insertrows = 3 + prodlength
    Rows("3:3").Copy
    Rows("4:" & insertrows).Insert

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "bundyloco" <[email protected]> wrote
    in message news:[email protected]...
    >
    > I'm trying to create a chunk of code that copies an entire row and then
    > inserts a variable amount. here is the code
    >
    > insertrows = 3 + prodlength
    > Rows("3:3").Select
    > Selection.Copy
    > Rows("4:insertows").Select
    > Selection.Insert Shift:=xlDown
    >
    > Is it possible to do something like this? I'm trying to do this method
    > because it copying and inserting rows preserves all the formatting. The
    > variable prodlenght is the number of products found off another
    > worksheet in the workbook.
    >
    >
    > --
    > bundyloco
    > ------------------------------------------------------------------------
    > bundyloco's Profile:

    http://www.excelforum.com/member.php...o&userid=23386
    > View this thread: http://www.excelforum.com/showthread...hreadid=399996
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1