Search code examples
excelexcel-formulaexcel-2019

Get last value in a column not equal to some value


I have an excel spreadsheet with a column with states where I have ran races. I would like to write a function that returns the last out of state race I ran. How would I do that?


Solution

  • You can use INDEX() to get the row number:

    =INDEX(MAX((A:A<>"")*(A:A<>"NJ")*(ROW(A:A))),0)
    

    enter image description here

    and INDEX() to get the value:

    =INDEX(A:A,INDEX(MAX(($A:$A<>"")*(A:A<>"NJ")*(ROW(A:A))),0))
    

    for the last value not equal to NJ.