Results 1 to 5 of 5

Help: Macro to Combine Match Data From Two Sheets

Threaded View

  1. #1
    Registered User
    Join Date
    08-24-2012
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    2

    Help: Macro to Combine Match Data From Two Sheets

    I have a workbook with two sheets, AB1matches and Sheet2. AB1matches has about 130,000 rows, while Sheet2 has about 800. I want to be able to take the first column of the AB1matches, and find a corresponding match from the first column of Sheet2. Every item in the first column of Sheet2 can be found in first column of AB1matches. I want to output the result to Sheet3, including all 14 columns of associated data from AB1matches(item number, product name, description, vendor, etc.) with the corresponding data from the match on Sheet2 from that match's row ( 7 columns total). This code is not throwing an error, however, it is just doing nothing, please help!:

    Sub Merge()
     
    intspot = 2
    
    For V1 = 2 To 1000
     intRepeated = 0
     For V2 = 2 To 140000
        If Sheets("AB1matches").Cells(V1, 15) = Sheets("AB1matches").Cells(V2, 1) Then
          intRepeated = 1
          Exit For
          End If
          Next V2
          If intRepeated = 0 Then
        Sheets("Sheet3").Cells(intspot, 1) = Sheets("AB1matches").Cells(V1, 1)
        Sheets("Sheet3").Cells(intspot, 2) = Sheets("AB1matches").Cells(V1, 2)
        Sheets("Sheet3").Cells(intspot, 3) = Sheets("AB1matches").Cells(V1, 3)
        Sheets("Sheet3").Cells(intspot, 4) = Sheets("AB1matches").Cells(V1, 4)
        Sheets("Sheet3").Cells(intspot, 5) = Sheets("AB1matches").Cells(V1, 5)
        Sheets("Sheet3").Cells(intspot, 6) = Sheets("AB1matches").Cells(V1, 6)
        Sheets("Sheet3").Cells(intspot, 7) = Sheets("AB1matches").Cells(V1, 7)
        Sheets("Sheet3").Cells(intspot, 8) = Sheets("AB1matches").Cells(V1, 8)
        Sheets("Sheet3").Cells(intspot, 9) = Sheets("AB1matches").Cells(V1, 9)
        Sheets("Sheet3").Cells(intspot, 10) = Sheets("AB1matches").Cells(V1, 10)
        Sheets("Sheet3").Cells(intspot, 11) = Sheets("AB1matches").Cells(V1, 11)
        Sheets("Sheet3").Cells(intspot, 12) = Sheets("AB1matches").Cells(V1, 12)
        Sheets("Sheet3").Cells(intspot, 13) = Sheets("AB1matches").Cells(V1, 13)
        Sheets("Sheet3").Cells(intspot, 14) = Sheets("AB1matches").Cells(V1, 14)
        Sheets("Sheet3").Cells(intspot, 15) = Sheets("Sheet2").Cells(V1, 1)
        Sheets("Sheet3").Cells(intspot, 16) = Sheets("Sheet2").Cells(V1, 2)
        Sheets("Sheet3").Cells(intspot, 17) = Sheets("Sheet2").Cells(V1, 3)
        Sheets("Sheet3").Cells(intspot, 18) = Sheets("Sheet2").Cells(V1, 4)
        Sheets("Sheet3").Cells(intspot, 19) = Sheets("Sheet2").Cells(V1, 5)
        Sheets("Sheet3").Cells(intspot, 20) = Sheets("Sheet2").Cells(V1, 6)
        Sheets("Sheet3").Cells(intspot, 21) = Sheets("Sheet2").Cells(V1, 7)
        
        intspot = intspot + 1
        
      End If
    Next V1
    End Sub
    Thanks
    Mike
    Last edited by Mike951; 08-24-2012 at 11:08 AM.

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