+ Reply to Thread
Results 1 to 5 of 5

How to copy/paste one row into multiple rows and automate it?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-01-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    How to copy/paste one row into multiple rows and automate it?

    Hi there,

    I have an excel file with data that has 7 columns and 912 rows. I want to take the first row and copy it into 10 rows. Then take the second row and copy it into the next 10 rows, and take the third row and copy it into the next 10 rows and so on for all rows.

    Please download the file here https://fileexchange.imperial.ac.uk/.../RowtoRows.xls



    In the attached file, on the left hand side I have my 7 columns and 912 rows (A2:G913) . To the right of this, I have created a sample of what I am trying to achieve. I have copy&pasted A3:G3 into J3:P12, also copy pasted A4:G4 into J13:P22 etc etc (this is what I am trying to achieve but for all rows)

    What formula can I use to do this quickly as it will take a long time to copy&paste manually?

    Thanks in advance.

  2. #2
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: How to copy/paste one row into multiple rows and automate it?

    Welcome to the forum.

    Something like this should work. You need to add this code to a standard module in your workbook.
    ALT+F11 to open the VBE
    Insert > Module
    Paste into the code pane on the right.
    Close the VBE.

    To run hit ALT+F8 and choose to run 'MyCopy' from the dialog.

    Option Explicit
    Sub MyCopy()
    Dim lngLastRow As Long
    Dim lngRow As Long
    lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
    For lngRow = 3 To lngLastRow
        Range(Cells(lngRow, "A"), Cells(lngRow, "G")).Copy _
            Cells(Rows.Count, "J").End(xlUp).Offset(1).Resize(10, 7)
    Next lngRow
    End Sub
    Regards

    Jon (Excel 2003, 2007, 2010, 2013)

  3. #3
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: How to copy/paste one row into multiple rows and automate it?

    A formula solution for your sample provided:

    =INDEX($A$3:$G$913,(ROW()-3)/10+1,MATCH(S$2,$A$2:$G$2,0))

    In J3 and copied down to end of range in column P. In this case it's P9112.

  4. #4
    Registered User
    Join Date
    06-01-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to copy/paste one row into multiple rows and automate it?

    Quote Originally Posted by JONvdHeyden View Post
    A formula solution for your sample provided:

    =INDEX($A$3:$G$913,(ROW()-3)/10+1,MATCH(S$2,$A$2:$G$2,0))

    In J3 and copied down to end of range in column P. In this case it's P9112.
    Hi thanks so much!

    This formula didnt work for some reason

  5. #5
    Registered User
    Join Date
    06-01-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How to copy/paste one row into multiple rows and automate it?

    Ok I think this was there was a typo. This works:

    =INDEX($A$3:$G$913,(ROW()-3)/10+1,MATCH(A$2,$A$2:$G$2,0)

    Thanks!

+ 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