I'm trying to match values in two tables and to copy the value in a destination table.
I understand this requires multiple loops / conditions.
The goal is to copy the matching values from source table (SE) to each row in destination table (FB) using the match in the helper table (SA).
There is no unique key value in column 'C' at table 'SA'.
My code so far:
Sub MatchTables()
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim i As Long, j As Long
Dim newSheetPos As Integer
Set ws1 = ActiveWorkbook.Sheets("FB") 'Range: last row
Set ws2 = ActiveWorkbook.Sheets("SA") 'Range: rows 5 to 84
Set ws3 = ActiveWorkbook.Sheets("SE") 'Range: last row
For i = 2 To ws1.Cells(ws1.Rows.Count, 3).End(xlUp).Row
For j = 5 To 84
If ws1.Cells(i, 3).Value = ws2.Cells(j, 3).Value Then
If ws2.Cells(i, 3).Value = ws3.Cells(j, 5).Value Then
ws3.Cells(j, 6).Copy ws1.Cells(i , 16)
Else
End If
Else
End If
Next j
Next i
End Sub
