I'm trying to do what should be a simple enough task: find the index of the last cell in an array that matches a certain value.

I am using a MATCH-INDEX function combination that is giving me incorrect, inconsistent results. I can't figure out the problem.

In this example I'm using an array with values of 1 or -1 and trying to find the index of the last 1 in the array.

[![Photo of index-match results](https://i.stack.imgur.com/i5jA8.png)](https://i.stack.imgur.com/i5jA8.png)

My understanding is (and using the Evaluate Formula tool confirms), INDEX(A1:F1=1,0) should return an array of

```
{FALSE,TRUE,FALSE,TRUE,FALSE,FALSE}

```

Why does the MATCH(TRUE,...) not give a result of 4 when it is fed this index array? MATCH works backwards in the array and should return the index of the last match, which is the TRUE value in the 4th position.

But here this code is giving a result of 6.

To make matters worse, if I use the same code but change around the array fed into INDEX, the results are inconsistent. When I'm changing array values to 1 or -1, sometimes the formula result changes and sometimes it doesn't, and I can't figure out why.

Below, changing only the 3rd array value changes the result of the formula from 4 to 6. WHAT IS GOING ON?!

[![Photo of index-match results (2nd array configuration)](https://i.stack.imgur.com/SrrjI.png)](https://i.stack.imgur.com/SrrjI.png)