How can I change the range of countif() inside an arrayformula()?

206 views Asked by At

I want to find duplicates that happen after the current row. I can find duplicates that happen anywhere with this formula but I don't want to flag the last occurrence of a particular value as being a duplicate.

=arrayformula(if(row(B:B) = 1, "Duplicate", if(not(isblank(A:A)), if(countif(A:A, A:A) > 1, "Yes", "No"), "")))

If I statically specify a starting cell in the lookup range it only finds duplicates after that spot. However I need to have the starting spot change based on the row I'm on.

=arrayformula(if(row(B:B) = 1, "Duplicate", if(not(isblank(A:A)), if(countif(A5:A, A:A) > 1, "Yes", "No"), "")))

I tried using indirect() and row() but it doesn't seem to update for each row.

=arrayformula(if(row(B:B) = 1, "Duplicate", if(not(isblank(A:A)), if(countif(indirect("A"&row(B:B)&":A"), A:A) > 1, "Yes", "No"), "")))

1

There are 1 answers

6
player0 On BEST ANSWER

try:

={"Duplicate"; ARRAYFORMULA(IF(INDIRECT("A"&ROW()+1&":A")<>"", 
 IF(COUNTIF(INDIRECT("A"&ROW()+1&":A"), INDIRECT("A"&ROW()+1&":A")) > 1, "Yes", "No"), ))}

0


UPDATE:

={"Duplicate"; 
 ARRAYFORMULA(IF(A2:A="",,
 IF(COUNTIFS(A2:A, A2:A, ROW(A2:A), ">="&ROW(A2:A))>1, "Yes", "No")))}

0