To do lookup with two criteria, in Excel-Formula, it would be written as:
{MATCH(1, 1*(A1:A5=100)*(B1:B5=150), 0)}
How do i write the above formula in VBA syntax for the WorksheetFunction.Match function?
Consider:
Sub dural()
Dim m As Long
With Application.WorksheetFunction
m = .Match(1, [1*(A1:A5=100)*(B1:B5=150)], 0)
End With
MsgBox m
End Sub
This shows both the array formula in the worksheet and the VBA equivalent.
I don't have enough rep to post a comment.. This is to aid anyone searching for how to use the answer from "Gary's Student" with variables. I wrestled with this for over an hour. The brackets [] used are a shortcut for evaluate(string) You have to replace those and wrap them in the evaluate method. Since the parameter is a string, you can construct the string yourself with the variables you need.
Sub dural()
Dim m As Long
With Application.WorksheetFunction
m = .Match(1, evaluate("1*(A1:A5=100)*(B1:B5=150)"), 0)
End With
MsgBox m
End Sub