1COUNTIF flag on every copy
=COUNTIF(A$2:A$11,A2)>1
- In B2 type =COUNTIF(A$2:A$11,A2)>1.
- Fill the formula down. TRUE marks any value that appears more than once.
- Turn on Data > Filter and filter column B to TRUE to see all duplicates together.
Flag duplicate values in a column with COUNTIF so you can filter, count and act on them, instead of only seeing them highlighted.
Conditional formatting can colour duplicate cells, which is useful for a quick look. It does not give you anything to filter on, count or hand to a formula. A formula that marks each row can do all three.
The core is COUNTIF, which counts how many times a value appears in a range. If the answer is greater than one, the value is a duplicate: =COUNTIF(A$2:A$11, A2)>1. The result is TRUE or FALSE, and you can filter on it with Data > Filter.
This marks every copy, including the first. Often you want to leave the first occurrence alone and flag only the repeats. Make the start of the range fixed and the end relative: =IF(COUNTIF(A$2:A2, A2)>1, "Repeat", ""). In row 2 the range is just A2, so a value cannot repeat. Further down, the range grows, so a value that appeared earlier is counted again and flagged.
That one dollar sign is the whole trick: A$2 stays anchored while A2 moves as you fill down. The Foundations track covers mixed references in detail.
If you do want colour, the ribbon way is Home > Conditional Formatting > Highlight Cells Rules > Duplicate Values. It marks all copies with no distinction, and does not leave a column you can sort.
Remember that COUNTIF ignores case and treats text and numbers as different. A code stored as text and the same code stored as a number will not match until you convert one of them.
=COUNTIF(A$2:A$11,A2)>1
=IF(COUNTIF(A$2:A2,A2)>1,"Repeat","")
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In B2, return TRUE if the invoice number in A2 appears more than once in A2:A11, otherwise FALSE. Fill down to B11.
Answer in B2, then it fills down to B11.
Excel foundations covers this in lesson 15, IF: your first decision.