I posted a question in regards to finding a match with multi-column criteria. The provided answer works great. But I'm trying to make it a universal solution for my project, in terms of how many columns criteria is used.
Here is the question I am referencing: Question & Answer I used
Here is what I've managed to come up with so far:
Public Function CRITERIA(ParamArray values() As Variant) As Variant
....
CRITERIA = values
End Function
Where the actual UDF referenced in the cells will be:
Public Function MULTIMATCHEXISTS(args As Variant, ParamArray colmns() As Variant) As Boolean
Dim argsCount As Long, colmnsCount As Long, cl As Long, a As Long
argsCount = UBound(args) - LBound(args) + 1
colmnsCount = UBound(colmns) - LBound(colmns) + 1
Dim tbl As ListObject
Dim ws As Worksheet
Dim lr As ListRow
Dim match_candidate As Variant, arg As Variant
If argsCount <> colmnsCount Then
....
Exit Function
Else
'Get the name of the table from any column provided (this of courses assumes a 1:1 table search)
Set tbl = colmns(0).ListObject
'Get tables worksheet from the table object
Set ws = ThisWorkbook.Sheets(tbl.Parent.Name)
'Iterate through columns?
For cl = LBound(colmns) To UBound(colmns)
'Get each value from column
For each lr In tbl.ListRows
match_candidate = Intersect(lr.Range, colmns(cl)).value
'Iterate through arguments?
For a = LBound(args) To UBound(args)
If match_candidate = args(a) Then
Debug.Print "its a match for " & args(a) & " in column " & colmns(cl)
MULTIMATCHEXISTS = True
Else
MULTIMATCHEXISTS = False
End If
Next a
Next lr
Next cl
End If
End Function
Where someone would use the UDF as follows:
=MULTIMATCHEXISTS(CRITERIA(A2,A3,A4), Table2[Column1], Table2[Column8], Table2[Column5])
Basically what I would like is for it to validate if the first value = it's respective queried column and so forth (I.e args(0) should = colmns(0) value, args(1) should = colmns(1) value)
So far, I can find matches using the above example, but I don't know how to check if ALL values match at the same time. Additionally I can't find any native functions to compare arrays on the MSDN site. It's an awkward site to navigate IMO.
Don't let my rep fool you. I'm new to VBA and will be the first to admit my newbiness, I'm having a hard time converting over. I don't find the MSDN documentation to be as helpful as other languages, personally. So if you can share any resources you use I would appreciate it.
In an effort to simplify my desired outcome:
Take table 1 that has a list of clients:
A B C D
-----------------------------------------------------------
1 | Name | Email | Phone | ISMATCH? |
-----------------------------------------------------------
2 | Steve Jobs | [email protected] | 123456 | True |
-----------------------------------------------------------
3 | Bill Gates | [email protected] | 123456 | True |
-----------------------------------------------------------
4 | Steve Woz | [email protected]| 123456 | False |
-----------------------------------------------------------
Take table 2 that has a detailed description of those clients, but every client is queried by different arguments:
J K L M
-----------------------------------------------------------
1 | Name | Company | Phone | Email |
-----------------------------------------------------------
2 | Steve Jobs | Apple | 123456 | [email protected] |
-----------------------------------------------------------
3 | Bill Gates | Apple | 123456 | [email protected] |
-----------------------------------------------------------
4 |Stevie Wonder | Apple | 123456 | [email protected] |
-----------------------------------------------------------
What I would like is to be able to pick and choose which criteria to evaluate and then select their corresponding columns in Table 2. So back in Table 1 D2 it would be something like this:
=MULTIMATCHEXISTS(CRITERIA([@NAME], [@EMAIL]), Table2[Name], Table2[Email])
But lets say for bill gates I want to check more than those 2 criteria, so Table 1 D3 would be:
=MULTIMATCHEXISTS(CRITERIA([@NAME], [@PHONE], [@EMAIL]), Table2[Name], Table2[Phone], Table2[Email])
And for Steve Woz Table 1 D4:
=MULTIMATCHEXISTS([@Name], Table2[Name])
Those are practical examples of my UDF in action. Im trying to make both arguments dynamically flexible. I live off of named ranges, but it doesn't have to be specific to that

MULTIMATCHEXISTS()returned values