r/vba•
webcamz

Multiple Match criteria not working in VBA (Mismatch Error)

Solved

So as a test, I have a spreadsheet with the numbers 1 in A1, 2 in B1, 3 in A2, 4 in B2, etc. like this: https://i.imgur.com/qdOoEXn.png

A regular Excel formula:

=MATCH(1, INDEX((5=A:A)*(6=B:B), 0, 1), 0)

works fine and displays 3 as the row number, which is correct since both 5 and 6 are in row 3.

I am trying to get this same code in VBA but I get a Type Mismatch error:

Sub test()

    Cells(10, 10).Value = Application.Match(1, Application.Index((5 = Range("A:A")) * (6 = Range("B:B")), 0, 1), 0)

End Sub

What am I doing incorrectly here?

Posted Dec 6, 2018, 1:23 AM UTC

35
Loading comments…