I'm working on this bit of code which returns the first match as the result.
Looking for some guidance or help to rewrite this to account for multiple matches - Criteria 2 is quite important as it changes later on in the data and needs to be accounted for (I feel I had to mention this as the data snippets I've provided only show a single possibility)
Here is the code
Here are some image references to assist in understanding the problem.
WRONG RESULT (Result is first match over all columns)
EXPECTED RESULT (Multiple matches returned)
Here is a snippet of the data sheet (sheet2)
Would appreciate any help I could get on the matter.
TIA
Looking for some guidance or help to rewrite this to account for multiple matches - Criteria 2 is quite important as it changes later on in the data and needs to be accounted for (I feel I had to mention this as the data snippets I've provided only show a single possibility)
Here is the code
VBA Code:
Sub Tester2()
Dim v, shtDest, shtSrc, a1, a2, i
Set shtDest = ThisWorkbook.Sheets("Sheet1")
Set shtSrc = ThisWorkbook.Sheets("Sheet2")
With ActiveSheet.ListObjects(1).DataBodyRange
For i = 2 To .Rows.Count
a1 = "'" & shtDest.Name & "'!" & shtDest.Cells(i, 7).Address(False, False)
a2 = "'" & shtDest.Name & "'!" & shtDest.Cells(i, 9).Address(False, False)
Debug.Print a1, a2
v = shtSrc.Evaluate("MATCH(" & a1 & "&" & a2 & ",D2:D29&H2:H29,0)")
If Not IsError(v) Then
shtDest.Cells(i, 8).Value = shtSrc.Range("J2:J29").Cells(v).Value
End If
Next i
End With
End Sub
Here are some image references to assist in understanding the problem.
WRONG RESULT (Result is first match over all columns)
EXPECTED RESULT (Multiple matches returned)
Here is a snippet of the data sheet (sheet2)
Would appreciate any help I could get on the matter.
TIA