Forum Discussion

Terence019740's avatar
Terence019740
Copper Contributor
May 11, 2024
Solved

formula to count the number of cells including the one which repeats itself

Good evening.   I would be very grateful if anyone could help with the below.   With regards the file attached.   you will see that column J has numerous numbers in said column.   is there a ...
  • djclements's avatar
    djclements
    May 12, 2024

    Terence019740 If you are using Excel for MS365 or Excel for the web, the SCAN function could be used as follows:

     

    =LET(
        rng, E6:E200,
        arr, TEXTAFTER(SCAN("1|", SEQUENCE(ROWS(rng)), LAMBDA(p,n, LET(
            r, TEXTBEFORE(p, "|"),
            a, INDEX(rng, r),
            b, INDEX(rng, n),
            IF(AND(COUNTIF(a:b, b)=2, b<>""), n+1&"|"&COUNT(a:b), r&"|")))), "|"),
        IF(arr="", arr, --arr)
    )

     

    With older versions of Excel, try the following formula in cell F6 and copy down as needed:

     

    =IF(AND(COUNTIF(INDEX($E$5:E6, IFNA(MATCH(1E+100, $F$5:F5, 1), 0)+1):E6, E6)=2, E6<>""), COUNT(INDEX($E$5:E6, IFNA(MATCH(1E+100, $F$5:F5, 1), 0)+1):E6), "")

     

    See attached...

Resources