Results 1 to 6 of 6

Thread: Need to paste multiple rows in Excel multiple times
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Mar 2006
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Need to paste multiple rows in Excel multiple times

    I am looking for a macro perhaps. I have 3 rows of data Columns C to G I want to paste multiple times. Perhaps thousands of times. Is there a way I can cope C1:G3 and then paste it a number of times? I would like in some cases this to be 300 times, and in other cases 1500 times.

  2. #2
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,804
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Need to paste multiple rows in Excel multiple times

    Where are you going to paste the rows ??
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

  3. #3
    New Member
    Join Date
    Mar 2006
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need to paste multiple rows in Excel multiple times

    Quote Originally Posted by Michael M View Post
    Where are you going to paste the rows ??
    Aha ... good point. It could be on a fresh worksheet, or below the 3 rows I am copying from.

  4. #4
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,804
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Need to paste multiple rows in Excel multiple times

    OK, this will post below the existing data

    Code:
    Sub MM1()
      Dim x As Integer, r1 As Range
       x = InputBox("Enter the number of times to copy the range")
      With Range("C1:G3")
        Set r1 = Cells(.Rows.Count + 1, .Column)
        .Copy r1.Resize(x * .Rows.Count)
        .Cells(1).Select
       End With
    End Sub
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

  5. #5
    New Member
    Join Date
    Mar 2006
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need to paste multiple rows in Excel multiple times

    Quote Originally Posted by Michael M View Post
    OK, this will post below the existing data

    Code:
    Sub MM1()
      Dim x As Integer, r1 As Range
       x = InputBox("Enter the number of times to copy the range")
      With Range("C1:G3")
        Set r1 = Cells(.Rows.Count + 1, .Column)
        .Copy r1.Resize(x * .Rows.Count)
        .Cells(1).Select
       End With
    End Sub
    thanks. That worked a treat. Is there also a way I can repeat a stack of single rows three times. I have many worksheets with cost center number in Col A and cost center names in Col B. I want each row to be repeated twice ... (i.e) (each spreadsheet has different information and differing amounts. But each row must be 3 times)

    Was

    A B
    349 Engineering assets
    220 Finance
    235 HR direct costs

    NEW

    A B
    349 Engineering assets
    349 Engineering assets
    349 Engineering assets
    220 Finance
    220 Finance
    220 Finance
    235 HR direct costs
    235 HR direct costs
    235 HR direct costs
    Last edited by litifeta; Sep 17th, 2019 at 03:49 PM. Reason: dsa

  6. #6
    Board Regular Michael M's Avatar
    Join Date
    Oct 2005
    Location
    South Western NSW
    Posts
    17,804
    Post Thanks / Like
    Mentioned
    18 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Need to paste multiple rows in Excel multiple times

    Try

    Code:
    Sub MM1()
    Dim r As Long, n As Integer
    n = InputBox("How many rows")
        For r = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
            Rows(r).Copy
            Rows(r).Resize(n).Insert
        Next r
    End Sub
    Regards
    Michael M
    ---------------------------------------
    The more I learn, the less I seem to know.....A Please and Thank You cost nothing !
    It's easier to debug if we can see the whole macro !
    Home 2007 & 2013

    - Posting guidelines, forum rules and terms of use

    - To download Mr Excel HTML Maker

    - Try searching for your answer first, see how

    - Read the FAQs

    - List of BB codes


    [CODE]Place Your Code Here[/CODE]

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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