VBA VLOOKUP with multiple conditions

syzer

New Member
Joined
May 11, 2024
Messages
12
Office Version
  1. 2021
Platform
  1. Windows
Hello!
I have a workbook that lists products we sell, for who, when and how many we have sold of each product. I would like to add macro into workbook, which based on multiple criterias can figurate the exact matching and return the requested relevant information, what I need.

To simplify my question, here is one example how it can be solve with excel functional method the request.
excel-vlookup-multiple-criteria.png


I would like to use this functional to defining the variable in the macro, but after running of macro always there is Type mismatch error occurs.

qty = Application.WorksheetFunction.Index(Range("D2:D11"), Application.WorksheetFunction.Match(1, (Range("G1") = Range("A2:A11")) * (Range("G2") = Range("B2:B11")) * (Range("G3") = Range("C2:C11")), 0))

Does somebody have idea how I can search relevant cell data based at least on 3 criterias do get the variable?

Thank you!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
The simplest workaround is going to be something like this:
VBA Code:
    qty = Evaluate("INDEX(D2:D11,MATCH(1,(A2:A11=G1)*(B2:B11=G2)*(C2:C11=G3),0),0)")
 
Upvote 1
Solution
The simplest workaround is going to be something like this:
VBA Code:
    qty = Evaluate("INDEX(D2:D11,MATCH(1,(A2:A11=G1)*(B2:B11=G2)*(C2:C11=G3),0),0)")

Thank you, it's very simple and fast solution in my case. The result evaluating is working perfectly!
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top