The goal of this formula is to return "size" when given an animal and a weight.
Note: this is an array formula and must be entered with Control + Shift + Enter
How this formula works
At the core, this is just an INDEX / MATCH formula. The problem in this case is that we need to "screen out" the extraneous entries in the table so we are left only with entries that correspond to the animal we are looking up.
This snippet tests the values in B5:B10 to see if they match the value in G6 (the animal). Where there is a match, the corresponding values in C5:C11 are returned. Where there is no match FALSE is returned. When G6 contains "cat", the resulting array looks like this:
This goes into the MATCH function as the array. The lookup value for match comes from G7, which contains the weight (9 lbs in the example).
Note that match is configured for approximate match by setting match_type to 1, and this requires that the values in C5:C11 must be sorted.
MATCH returns the position of the weight in the array, and this is passed to INDEX as the row number. The lookup_array for INDEX are the sizes in D5:D10, so INDEX returns a size corresponding to the position generated by MATCH (the number 4 in the example shown).
The Excel INDEX function returns the value at a given position in a range or array. You can use index to retrieve individual values or entire rows and columns. INDEX is often used with the MATCH function, where MATCH locates and feeds a position to...
MATCH is an Excel function used to locate the position of a lookup value in a row, column, or table. MATCH supports approximate and exact matching, and wildcards (* ?) for partial matches. Often, the INDEX...
The IF function can perform a logical test and return one value for a TRUE result, and another for a FALSE result. For example, to "pass" scores above 70: =IF(A1>70,"Pass","Fail"). More than one condition can be tested by nesting IF functions....
Excel Formula Training
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.