Compare and Match 2 cols in 2 wkshts and return data

TheOneNOnlyQ

New Member
Joined
Feb 5, 2015
Messages
1
I have one workbook with 6 tabs.
On tab 1 I have a last name, first name, some other columns with stuff in them and 5 empty columns.
On tabs 2 - 6, I have a last name col, first name col and numbered data in the 3rd col.
I want to fill the 5 empty cols in tab 1 with the numbered data from tabs 2 - 6 IF the first AND last names match (capitalizations may be off) tab 1.
(The blank columns in tab1 correspond to weeks. Each tab, 2 - 6, corresponds to a weeks data. So tab2's numbered data would go into the first blank col, tab3's data would go into the second blank col...)
**Ideally, if a persons name is in any of the tabs 2 - 6 but not on tab 1, their first, last and numbered data would be added at the bottom of the data in tab1 (but that's a wishlist item)**

Tab 1
567782JohnsonannZMMy6HiTG8
236821jonesfredid9s78PP9cg
399722smithGeorgeCi88spl00La

<tbody>
</tbody>


Tab 2 (through 6 are formatted the same with different data)
andersoncheryl15
JonesFred6
Smithjordan7
JOHNSONAnn97
jonesfredricka21

<tbody>
</tbody>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hello,

does this code work as expected?

Code:
Sub GET_DATA()
    With Sheets(1)
        For MY_ROWS = 1 To .Range("A" & Rows.Count).End(xlUp).Row
            MY_NAME = UCase(.Range("B" & MY_ROWS).Value & UCase(.Range("C" & MY_ROWS).Value))
            For MY_SHEETS = 2 To 6
                With Sheets(MY_SHEETS)
                    For MY_NEW_ROWS = 1 To .Range("A" & Rows.Count).End(xlUp).Row
                        MY_NEW_NAME = UCase(.Range("A" & MY_NEW_ROWS).Value & UCase(.Range("B" & MY_NEW_ROWS).Value))
                        If MY_NAME = MY_NEW_NAME Then
                            Sheets(1).Cells(MY_ROWS, 4 + MY_SHEETS).Value = .Range("C" & MY_NEW_ROWS).Value
                        End If
                    Next MY_NEW_ROWS
                End With
            Next MY_SHEETS
        Next MY_ROWS
    End With
End Sub
 
Upvote 0
Hello,
and with your wish list

Code:
Sub GET_DATA()
    For MY_SHEETS = 2 To 6
        With Sheets(MY_SHEETS)
            For MY_NEW_ROWS = 1 To .Range("A" & Rows.Count).End(xlUp).Row
                MY_NEW_NAME = UCase(.Range("A" & MY_NEW_ROWS).Value & UCase(.Range("B" & MY_NEW_ROWS).Value))
                With Sheets(1)
                    For MY_ROWS = 1 To .Range("B" & Rows.Count).End(xlUp).Row
                        MY_NAME = UCase(.Range("B" & MY_ROWS).Value & UCase(.Range("C" & MY_ROWS).Value))
                            If MY_NAME = MY_NEW_NAME Then GoTo FOUND
                    Next MY_ROWS
                    .Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets(MY_SHEETS).Range("A" & MY_NEW_ROWS).Value
                    .Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets(MY_SHEETS).Range("B" & MY_NEW_ROWS).Value
                End With
FOUND:
            Next MY_NEW_ROWS
        End With
    Next MY_SHEETS
    With Sheets(1)
        For MY_ROWS = 1 To .Range("B" & Rows.Count).End(xlUp).Row
            MY_NAME = UCase(.Range("B" & MY_ROWS).Value & UCase(.Range("C" & MY_ROWS).Value))
            For MY_SHEETS = 2 To 6
                With Sheets(MY_SHEETS)
                    For MY_NEW_ROWS = 1 To .Range("A" & Rows.Count).End(xlUp).Row
                        MY_NEW_NAME = UCase(.Range("A" & MY_NEW_ROWS).Value & UCase(.Range("B" & MY_NEW_ROWS).Value))
                        If MY_NAME = MY_NEW_NAME Then
                            Sheets(1).Cells(MY_ROWS, 4 + MY_SHEETS).Value = .Range("C" & MY_NEW_ROWS).Value
                        End If
                    Next MY_NEW_ROWS
                End With
            Next MY_SHEETS
        Next MY_ROWS
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,218,219
Messages
6,141,224
Members
450,343
Latest member
patrickkw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top