简体   繁体   中英

MS Excel: Count the number of cells in a column that have the same number as the cell to the left of it

How can I do to count the number of cells in a column, that have the same text as the cell to the left of it?

Seems it should be pretty simple but I can't find a way or any answer online. Thank you.

=COUNTIF(P$2:P$125,"="&$O2)

=COUNTIF(P$2:P$125,"="&$O2)

This is almost perfect except the formula tries to match always with cell value of O2. Which is great for P2, but when I get to P99 for example, I want to see if it is exactly the same as O99, and similarly then equal.

Use SUMPRODUCT and limit the ranges to the extents of the data while maintaining the same size of range for both columns.

=SUMPRODUCT(--(O$2:O$125=P$2:P$125))
'dynamic range
=SUMPRODUCT(--(O$2:index(O:O, match("zzz", O:O))=P$2:index(P:P, match("zzz", O:O))))

The -- (or double unary ) coverts the TRUE/FALSE results to ones and zeroes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM