Table of Contents
The use of INDEX MATCH with multiple criteria in VBA allows for efficient and accurate data retrieval from large datasets. This method utilizes the INDEX function to locate a specific value within a table or range, and the MATCH function to specify the criteria for the desired value. By combining these two functions, VBA can perform complex searches and return precise results, making it a valuable tool for data analysis and manipulation. This technique can be particularly useful for automating tasks and creating dynamic reports in Excel, making it a highly versatile feature for VBA users.
VBA: Use INDEX MATCH with Multiple Criteria
You can use the following basic syntax to perform an INDEX MATCH with multiple criteria in VBA:
Sub IndexMatchMultiple()
Range("F3").Value = WorksheetFunction.Index(Range("C2:C10"), _
WorksheetFunction.Match(Range("F1"), Range("A2:A10"), 0) + _
WorksheetFunction.Match(Range("F2"), Range("B2:B10"), 0) - 1)
End Sub
This particular example looks up the value in cell F1 within the range A2:A10 and the value in cell F2 within the range B2:B10 and returns the corresponding value in the range C2:C10 to cell F3.
The following example shows how to use this syntax in practice.
Example: Perform INDEX MATCH with Multiple Criteria Using VBA
Suppose we have the following dataset in Excel that contains information about basketball players:

Suppose we would like to look up the player that matches the team name in cell F1 and the position in cell F2 and return the name in cell F3.
We can create the following macro to do so:
Sub IndexMatchMultiple()
Range("F3").Value = WorksheetFunction.Index(Range("C2:C10"), _
WorksheetFunction.Match(Range("F1"), Range("A2:A10"), 0) + _
WorksheetFunction.Match(Range("F2"), Range("B2:B10"), 0) - 1)
End SubWhen we run this macro, we receive the following output:

The macro looks up “Spurs” in the Team column and “Forward” in the Position column and correctly returns the name “Eric” in cell F3.
If we change the values in cells F1 and F2 and run the macro again, it will be able to find the player name based on the new values.
For example, suppose we change the team name to “Mavs” and position to Center” and run the macro again:

The macro looks up “Mavs” in the Team column and Center” in the Position column and correctly returns the name Chad” in cell F3.
Cite this article
stats writer (2024). How can I use INDEX MATCH with multiple criteria in VBA?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-index-match-with-multiple-criteria-in-vba/
stats writer. "How can I use INDEX MATCH with multiple criteria in VBA?." PSYCHOLOGICAL SCALES, 24 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-index-match-with-multiple-criteria-in-vba/.
stats writer. "How can I use INDEX MATCH with multiple criteria in VBA?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-index-match-with-multiple-criteria-in-vba/.
stats writer (2024) 'How can I use INDEX MATCH with multiple criteria in VBA?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-index-match-with-multiple-criteria-in-vba/.
[1] stats writer, "How can I use INDEX MATCH with multiple criteria in VBA?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I use INDEX MATCH with multiple criteria in VBA?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
