This article shows how to get last match by using MAX, MIN, IF and ROW functions. Excel's array formula ability to evaluate formula for each cells in an array is key factor in this case.


{ =MAX( IF( data = search value, ROW( data ) - MIN( ROW( data ) ) + 1 ) ) }


  1. Start with MAX function =MAX(
  2. Continue with IF function IF(
  3. Enter the match condition by using whole data range in an equation E3:E11=I3,
  4. Continue to next argument with ROW function and data range again ROW(E3:E11)
  5. Subtract following by previous step -MIN(ROW(E3:E11))
  6. Add 1 to calculation +1
  7. Close both formulas ))
  8. Press CTRL + SHIFT + ENTER instead of regular ENTER key to define formula as an array formula.


The logic is to find the maximum row number of the last occurrence of a match. Certainly, the finding maximum part is the easy part that Excel already has the MAX formula which can do the job without effort. So, let's check the remaining.

Relative Row Numbers

First of all; we need relative row numbers of data array that we can use it with the condition. The ROW function can easily give the row numbers of a range. When we use it in an array formula, it returns an array that includes the row numbers of each cell. To find the relative row numbers, we need to subtract first row of the range by row values of each cell. Also, adding 1 ensures that the row numbers start from 1.

ROW(E3:E11) returns {3;4;5;6;7;8;9;10;11}

MIN(ROW(E3:E11)) returns 3

As a result; ROW(E3:E11)-MIN(ROW(E3:E11))+1 returns {1;2;3;4;5;6;7;8;9}


Next, we use the array of relative row numbers with the IF function which has a condition for search value. Simple equation condition can do the job. Because we will use array formula, it is OK to use a range and a cell in equation. The array formula structure forces Excel to make calculations for each cell in the range. Here is the result for equation:


Combining TRUE/FALSE Boolean values with the row numbers returns the row numbers that condition is met.

IF(E3:E11=I3,ROW(E3:E11)-MIN(ROW(E3:E11))+1) returns {FALSE;2;FALSE;FALSE;5;FALSE;FALSE;8;FALSE}


Finally, we can return to the MAX function. The MAX function evaluates Boolean values as 1 and 0 for TRUE and FALSE respectively. So, FALSE values are nothing in a MAX formula with positive numbers. The highest number indicates the position of the latest occurrence of search value.


Above all, the most important step is to press CTRL + SHIFT + ENTER rather than regular ENTER key to define the formula as an array formula. Otherwise, you see number 1 as the result.


You can apply same logic for horizontal list just by converting the ROW functions with the COLUMN. Hence, a sample formula looks like this: