Question : How to fix Excel VB code for a worksheet cross check

I am trying to create a cross-check so that one worksheet searches through other worksheets for matches and outputs all matched data (per person/company) to the third worksheet.

I have included a small sample of what I am dealing with.

It could be my structure, and maybe a pivot table would help (i don't know pivot tables).

It could be that i don't know how far different types of variables can reach.

The Production listings will always have many more listings (column wise) than company_history
I want to be able to use the Company_History list to search through production listings for matches
I need to match any part
I need it to output to this worksheet (or the same one if necessary, but separate is perfered)
I need it to output the entire row data from publish thru company 5
I need it to be sortable per person matched, since there will probably be many maches.

If this needs to be restructured please let me know, I am open to ideas

There are currently about 460 ACTUAL production listings, and 150 actual company_histories

The code is what I currently have, but it is not working and i don't know VB coding, so I can not fix it.

Please help fix my code.

Again, any ideas are welcome.

Thank you.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/17/2009 by Roy Weil
'
numCompanyRows = 150
numProductionRow = 460
'
    Sheets("Company_Listings").Select
    For iirow = 1 To numCompanyRows
        producer = Range("I" & iirow).Value ' get the producer
        Sheets("Production_Listings").Select
        For jjrow = 1 To numProductionRow
            If match(producer, Range("d" & jjrow).Value) Then
                saveRow (jjrow)
            ElseIf match(producer, Range("E" & jjrow).Value) Then
                saveRow (jjrow)
            ElseIf match(producer, Range("F" & jjrow).Value) Then
                saveRow (jjrow)
            End If
        Next
    Next
End Sub
 
 
 Function match(aa, bb)
    If (aa = bb) Then
         match = True
    Else
         match = False
    End If
End Function
            
Sub saveRow(jj)
    Sheets("Cross-Reference").Select
    For iirow = 1 To 1000   ' find the next empty row
        If (Range("A" & iirow).Value = "") Then
            newrow = iirow & ":" & iirow
            Exit For
        End If
    Next
    Sheets("Production_Listings").Select     'get data to copy
    temp = jj & ":" & jj
    Range(temp).Select
    Selection.Copy
    Sheets("Cross-Reference").Select
    Range(newrow).Select
    ActiveSheet.Paste
End Sub
Open in New Window Select All

Answer : How to fix Excel VB code for a worksheet cross check

The file I gave you checks specific columns within your spreadsheet for matching data, if you are having problems it is because your 'actual' spreadsheets do not have the same layout as the example you posted.

Upload an accurate example and I will adjust the settings to match.
Random Solutions  
 
programming4us programming4us