+ Reply to Thread
Results 1 to 10 of 10

Macro to copy data multiple times

Hybrid View

  1. #1
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Macro to copy data multiple times

    you last data set started on row 2 so i edited the macro to start at row 2, bellow is code to start at row 1

    Sub makelist()
        Dim arSheet1(), arSheet2() As String
        Dim str1, str2
        
        ActiveWorkbook.Sheets(1).Select
        
        ReDim arSheet1(1 To Range("A100000").End(xlUp).Row)
        For r = 1 To Range("A100000").End(xlUp).Row
            arSheet1(r) = Range("A" & r).Value
        Next
        
        ActiveWorkbook.Sheets(2).Select
        ReDim arSheet2(1 To Range("A100000").End(xlUp).Row)
        For r = 1 To Range("A100000").End(xlUp).Row
            arSheet2(r) = Range("A" & r).Value
        Next
        
        ActiveWorkbook.Sheets(3).Select
        r = 1
        For Each str2 In arSheet2()
            For Each str1 In arSheet1()
                Range("A" & r).Value = str2
                Range("B" & r).Value = str1
                r = r + 1
            Next
        Next
    End Sub
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  2. #2
    Registered User
    Join Date
    03-15-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro to copy data multiple times

    Thanks again for a swift reply, however it is still not the output i would like, your code dupliactes the rows, but puts the numbers against the numbers not letters with numbers and also overwrites the sheet 1 not placing it on sheet 3

    You code in in book 1 attached and the output i want is in sheet 3 of book 3

    ThanksBook1.xlsmBook3.xlsx

+ 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