Home » excel » Excel MATCH + COUNTIF function: retrieving the nth value in an array

Excel MATCH + COUNTIF function: retrieving the nth value in an array

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have a formula that I’m using in Excel to return the row # of the first item that matches a specified value.

Formula: =MATCH(0,COUNTIF($B$1,List),0) + CTRL + SHIFT + ENTER and in Mac: CMD + RETURN

Becomes:

MATCH(0,{**0**;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0},0)

Outputs: 1

I would like to update the function so that I can find the 2nd, 3rd, etc. instance that matches the specified value.

Like This:

MATCH(0,{0;**0**;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0},0)

And this outputs: 2

How to&Answers:

Doesn’t your current formula find the position of the first value in list that doesn’t match B1?

For 2nd try this array formula

=SMALL(IF(List<>$B$1,ROW(List)-MIN(ROW(List))+1),2)

replace the 2 with any value n for nth match. Assumes List is a single column

Answer:

You can move the list dynamically every time an occurrence is found so that for the next occurrence the list will begin from the last position found.

use this MATCH(<Match value>,INDIRECT(" <column of data> " & <Last position found> +1 & ":<Column of Data><Last Row Of Data>"),0)+<Last position found>

please see this : filter dynamic