Where “names” is the named range C4:C11. Note: this is an array formula and must be entered with control + shift + enter. Working from the inside out, this part of the formula will generate a relative set of row numbers: The result of the above expression is an array of numbers like this: Notice we get 8 numbers, corresponding to the 8 rows in the table. See this page for details on how this part of the formula works. For the purpose of this formula, we only want row numbers for matching values, so we use the IF function to filter the values like so: This results in an array that looks like this: Note this array still contains eight items. However, only row numbers where the value in the named range “names” is equal to “amy” have survived (i.e. 1, 4, 7). All other items in the array are FALSE, since they failed the logical test in the IF function. Finally, the IF function delivers this array to the MAX function. MAX returns the highest value in the array, the number 7, which corresponds to the last row number where the name is “amy”. Once we know the last matching row number, we can use INDEX to retrieve a value at that position.

Second to last, etc.

To get the second to last position, third to last, etc. you can switch from MIN function to the LARGE function like this: where k represents “nth largest”. For example, to get the second to last match in the example above, you can use: As before, this is an array formula and must be entered with control + shift + enter.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.