Excel Practice Test

โ–ถ

Highlighting Duplicates in Excel

4 Methods
Ways to Highlight Duplicates
Built-In
Conditional Formatting Rule
COUNTIF
Formula for Custom Highlighting
Real-Time
Updates as Data Changes
Excel 2010+
Minimum Version Required
Any Color
Customizable Highlight Color

How to Highlight Duplicates in Excel

Excel's Conditional Formatting feature lets you automatically highlight duplicate values in a column or range with any color you choose. The highlight updates dynamically โ€” when you add new data that creates a duplicate, Excel colors it immediately without manual action. When you delete one of the duplicates, the highlight on the remaining value disappears automatically.

The fastest method uses Excel's built-in duplicate highlighting rule, which takes about 10 seconds. Select your data range, go to Home โ†’ Conditional Formatting โ†’ Highlight Cells Rules โ†’ Duplicate Values, choose your color, and click OK. That's it โ€” every value that appears more than once in the selection is highlighted. This works well for simple single-column duplicate detection.

For more control โ€” highlighting only values that appear three or more times, highlighting across multiple columns, or highlighting entire rows when a specific column has a duplicate โ€” you'll need COUNTIF-based custom formulas. These take a few more steps but give you precise control over what gets highlighted and how. The Excel Skills Guide covers Conditional Formatting in the context of the broader Excel feature set if you want deeper background on how the formatting engine works.

Method 1: Built-In Duplicate Highlighting Rule

This is the fastest way to highlight duplicates in a single column or range. Here's the step-by-step process:

First, select the cells you want to check. You can select a single column (click the column header), a specific range (click and drag), or multiple non-contiguous ranges (hold Ctrl while selecting). Don't include headers unless you want the header cell highlighted if it matches a value below it โ€” most people exclude headers from the selection.

With your range selected, go to the Home tab on the ribbon. In the Styles group, click Conditional Formatting. In the dropdown menu, hover over Highlight Cells Rules. In the submenu that appears, click Duplicate Values. A dialog box opens.

The left dropdown says "Duplicate" (you can change it to "Unique" if you want to highlight unique values instead). The right dropdown shows color options: Light Red Fill with Dark Red Text, Yellow Fill with Dark Yellow Text, Green Fill with Dark Green Text, or Custom Format. Choose your preferred color and click OK. Excel immediately highlights every value that appears more than once in your selection.

Practice Free Excel Questions

When to Use Each Method

๐Ÿ”ด Built-In Rule (Fastest)

Use when you need to quickly identify duplicate values in a single column or a simple range. Takes 10 seconds. Best for: auditing a customer list, checking for duplicate product codes, reviewing imported data for repeats. Limitation: highlights any duplicate count โ€” a value appearing 2 times gets the same treatment as one appearing 100 times.

๐ŸŸ  COUNTIF Formula (Custom Control)

Use when you need to define exactly what counts as a 'duplicate' โ€” values appearing 3+ times, duplicates in a specific column that drive row-level highlighting, or conditional logic that goes beyond a simple repeat. More setup required, but much more flexible. Best for complex data auditing scenarios.

๐ŸŸก Highlight Entire Rows

When a dataset has multiple columns and you want to highlight the entire row when a specific column has a duplicate โ€” not just the cell. Requires a COUNTIF formula with a locked column reference ($A$2:$A$100) applied to the whole table range. Common for customer databases, order logs, and inventory tracking.

๐ŸŸข Compare Two Columns

When you want to highlight values in column A that also appear in column B, or vice versa. The built-in rule doesn't support this directly. Use COUNTIF with a cross-column formula: =COUNTIF($B:$B,A1)>0 applied to column A highlights every cell in A that has a match in B.

๐Ÿ”ต Case-Sensitive Duplicates

Excel's default duplicate detection is case-insensitive โ€” 'apple' and 'Apple' are treated as the same value. For case-sensitive detection, use EXACT() in an array formula within Conditional Formatting. This is an advanced technique needed when case matters for your data (e.g., product codes, passwords, case-sensitive identifiers).

๐ŸŸฃ After Highlighting: Delete Duplicates

Highlighting shows you where duplicates are but doesn't remove them. Once you've reviewed highlighted cells, use Data โ†’ Remove Duplicates to delete them, or manually delete the rows you don't want. The Remove Duplicates feature permanently deletes rows โ€” always work on a copy of your data first.

Method 2: COUNTIF Formula for Custom Duplicate Rules

The COUNTIF approach uses Conditional Formatting with a custom formula instead of the built-in rule. This gives you precise control over the duplicate threshold and the range being checked.

Select your data range first โ€” for example, A2:A100 for a column of values excluding the header. Go to Home โ†’ Conditional Formatting โ†’ New Rule. In the dialog, select "Use a formula to determine which cells to format." In the formula box, enter: =COUNTIF($A$2:$A$100,A2)>1

This formula says: count how many times the value in A2 appears in the entire range A2:A100 โ€” if it's more than once, apply the format. The dollar signs on the range ($A$2:$A$100) are critical โ€” they lock the range so it doesn't shift as the rule applies to each cell. The A2 reference without dollar signs shifts down with each row, checking each cell against the full range. Click Format, choose your color, click OK twice.

To highlight only values appearing 3 or more times, change >1 to >2. To highlight values appearing exactly twice, use =COUNTIF($A$2:$A$100,A2)=2. To highlight the most frequent values specifically, combine with COUNTIF and MAX โ€” though this gets complex. For most use cases, the >1 threshold is what you need.

Advanced Duplicate Highlighting Scenarios

๐Ÿ“‹ Highlight Entire Rows

To highlight entire rows when a specific column has a duplicate, select the entire table range first (e.g., A2:D100 for a 4-column table). Then go to Conditional Formatting โ†’ New Rule โ†’ Use a formula. Enter: =COUNTIF($A$2:$A$100,$A2)>1. The key is $A2 โ€” the dollar sign locks the column to A but lets the row shift, so the formula always checks column A for duplicates but applies the color to all columns in the row. This is the standard technique for row-level duplicate highlighting.

๐Ÿ“‹ Compare Two Columns

To highlight cells in column A that have a match in column B, select column A (or A2:A100). Add a Conditional Formatting rule with formula: =COUNTIF($B:$B,A2)>0. This highlights every A cell that appears at least once in column B. To find values in A that are NOT in B (mismatches), use: =COUNTIF($B:$B,A2)=0. This two-column comparison technique is useful for reconciling lists โ€” matching customer IDs across two datasets, checking inventory against orders, or verifying import/export data matches.

๐Ÿ“‹ Highlight Unique Values Only

The built-in Duplicate Values dialog has a "Unique" option in the left dropdown โ€” switch from "Duplicate" to "Unique" to highlight only values that appear exactly once. With COUNTIF formulas, use: =COUNTIF($A$2:$A$100,A2)=1. Unique value highlighting is useful when you want to spot anomalies in otherwise repetitive data โ€” finding the one order with no corresponding duplicate, or identifying the unique entry in a list that should have matched pairs.

๐Ÿ“‹ Highlight in Multiple Columns

The built-in rule checks for duplicates within the selected range as a whole โ€” so selecting A2:B100 highlights values that appear more than once across both columns combined, not separately. To check each column independently, apply the rule separately to each column. To check for rows where every column matches (full row duplicates), use COUNTIFS with multiple criteria: =COUNTIFS($A$2:$A$100,$A2,$B$2:$B$100,$B2)>1. This highlights rows only when both column A and column B match another row โ€” useful for detecting exact duplicate records.

Method 3: Highlight Duplicates Across Multiple Columns

When your data spans multiple columns and you want to find full row duplicates โ€” rows where every column matches another row โ€” the approach is more involved. The challenge is that Excel's built-in duplicate rule only looks at whether a cell value appears more than once in the selected range, not whether the combination of values across all columns of a row is duplicated.

For full row duplicate detection, you need a helper column or a COUNTIFS formula. The COUNTIFS approach uses multiple criteria, one per column. For a 3-column dataset in columns A, B, C starting at row 2, the formula would be: =COUNTIFS($A$2:$A$100,$A2,$B$2:$B$100,$B2,$C$2:$C$100,$C2)>1

Apply this as a Conditional Formatting rule to the entire table range (A2:C100). It highlights rows only when the combination of all three columns matches at least one other row exactly. This is the right approach for detecting exact duplicate records in a database โ€” where a customer might appear twice with identical name, email, and phone number, but slightly different entries wouldn't flag as duplicates.

An alternative for complex duplicate detection is creating a helper column that concatenates all the fields: =A2&"|"&B2&"|"&C2. This creates a unique string for each row's combination of values. Then use the built-in duplicate rule on the helper column โ€” any duplicate strings indicate rows with identical combinations across all three original columns. You can hide the helper column after setting up the rule; the conditional formatting continues to work. This approach is often easier to audit and modify than complex COUNTIFS formulas, especially for non-technical users who need to maintain the spreadsheet.

Method 4: Highlighting Duplicates with Different Colors by Count

What if you want to visually distinguish between values that appear twice versus values that appear three, four, or five times? Excel's built-in rule treats all duplicates identically, but multiple Conditional Formatting rules with different colors let you create a frequency-based color scale.

To apply color-coded frequency highlighting, you add multiple rules with different color formats and different COUNTIF thresholds. The rules must be applied in order from highest count to lowest, because Conditional Formatting applies rules in priority order and stops at the first match by default โ€” or continues through all rules if you check the "Stop if true" option carefully.

Here's the approach for three-tier frequency highlighting: Select your range and add three Conditional Formatting rules with formulas. First rule (red, highest priority): =COUNTIF($A$2:$A$100,A2)>=5. Second rule (orange): =COUNTIF($A$2:$A$100,A2)>=3. Third rule (yellow): =COUNTIF($A$2:$A$100,A2)>1. With these three rules, values appearing 5+ times are red; values appearing 3โ€“4 times are orange; values appearing exactly twice are yellow; values appearing once have no fill.

The order of rules matters. If yellow is applied first and "Stop if true" isn't set, a value appearing 10 times would match the yellow rule first and never reach red. In the Manage Rules dialog (Conditional Formatting โ†’ Manage Rules), use the up/down arrows to reorder rules โ€” highest threshold at the top. Make sure "Stop if true" is unchecked for the lower-priority rules so higher-priority rules take precedence. This multi-rule approach is particularly useful for quality control scenarios where you need to immediately spot high-frequency data issues that require urgent attention.

Once you've mastered highlighting, the natural next step is using Excel's remove duplicates feature to clean up the flagged data after you've reviewed which duplicates should be kept and which should be deleted. The combination of visual highlighting first, then targeted removal, gives you the most control over data cleanup workflows โ€” you see exactly what will be deleted before any permanent changes are made, which is the right approach when data accuracy matters.

Troubleshooting: Why Isn't My Duplicate Highlighting Working?

If your Conditional Formatting duplicate rule doesn't seem to be working correctly, a few specific causes account for most problems.

Spaces and invisible characters. The value "apple" and "apple " (with a trailing space) are treated as different values by Excel. If two cells look identical but one doesn't highlight, select both and look at the formula bar to check for leading or trailing spaces. Use TRIM() in a helper column to clean the data, or use Find & Replace (Ctrl+H) to replace a space with nothing to clean up spacing issues before applying your rule.

Number formatting. A cell with the number 42 formatted as text and a cell with the number 42 formatted as a number look identical but are different values to Excel. This commonly happens when data is imported from CSV files or other systems โ€” one column stores numbers as text while another stores them as numbers. You'll see the green error triangles in the corners of text-formatted number cells. Use the yellow warning indicator to convert to numbers, or use VALUE() in a helper column.

Wrong relative/absolute references. The most common formula error โ€” explained in the alert box above. Double-check that your COUNTIF range uses absolute references ($A$2:$A$100) and your cell reference is relative (A2 without dollar signs).

Rule applies to wrong range. In the Manage Rules dialog, check what range the rule is applied to. If you selected the whole column (A:A) but the formula references A2:A100, cells outside that range won't highlight correctly. Make sure the "Applies to" range in Manage Rules matches the range your formula references.

Hidden rows or filtered data. Conditional Formatting applies to all data regardless of whether rows are filtered or hidden. If you see unexpected highlighting, unhide rows or clear filters to see all data and verify which values are actually duplicated in the full dataset.

Case sensitivity. Excel's COUNTIF is case-insensitive by default. "Apple" and "apple" are treated as duplicates. If you need case-sensitive duplicate detection, you need an array-based EXACT formula โ€” the standard approaches don't support case sensitivity without workarounds.

Performance Tips for Large Datasets

Conditional Formatting can slow down Excel significantly on large datasets โ€” spreadsheets with 50,000 or more rows, or multiple formatting rules applied to large ranges. If your workbook feels sluggish after adding duplicate highlighting, a few approaches help.

First, avoid using entire column references (A:A) in Conditional Formatting rules. Instead of selecting column A entirely, select only the range that actually contains data (A2:A50000). Applying a COUNTIF formula to a million-cell range is far slower than applying it to the actual data range, even if most of those million cells are empty. Excel still evaluates the formula for every cell in the applied range.

Second, if you need to check duplicates but don't need live updates, consider using a helper column with a static COUNTIF formula instead of Conditional Formatting. A helper column with =COUNTIF($A$2:$A$50000,A2) calculates once when you enter it and doesn't recalculate unless the data changes. You can then sort or filter by the helper column to identify duplicates without the real-time performance overhead of Conditional Formatting.

Third, reduce the number of active Conditional Formatting rules. Multiple rules applied to large ranges compound the performance impact. If you've built up many formatting rules over time, audit them through Manage Rules and delete any that are no longer needed. Redundant and obsolete rules from old analyses are a common source of workbook slowness.

Fourth, if you work with very large datasets regularly, consider whether Excel is the right tool. Power Query (available in Excel 2016+) handles duplicate detection and data cleaning more efficiently at scale than Conditional Formatting, and writes results to a separate output table rather than modifying your source data. For one-time analysis on a very large file, Power Query is often both faster and significantly safer than Conditional Formatting approaches โ€” it processes data as a transformation step rather than a live formula applied to every single cell in your range.

Highlighting Duplicates in Google Sheets vs. Excel

If you work between Excel and Google Sheets, it's worth knowing that duplicate highlighting works slightly differently in each. Google Sheets has Conditional Formatting but doesn't have a built-in duplicate detection rule like Excel's Highlight Cells Rules โ†’ Duplicate Values shortcut. In Sheets, you must use the custom formula approach for all duplicate detection.

In Google Sheets, the COUNTIF formula approach is identical to Excel: select your range, go to Format โ†’ Conditional Formatting โ†’ Custom formula is, and enter =COUNTIF($A$2:$A$100,A2)>1. The formula syntax and absolute/relative reference logic are the same. The interface looks different โ€” Sheets uses a sidebar rather than a dialog box โ€” but the logic is the same.

One difference: Google Sheets' Conditional Formatting is generally faster to apply to large ranges than Excel's, because Sheets calculates in the cloud and handles concurrent computations differently. However, Sheets has a lower practical limit on the complexity of custom conditional formatting rules before performance degrades noticeably.

Files move between Excel and Sheets without losing Conditional Formatting rules โ€” the rules translate and continue to work after upload or download. The custom formula rules translate especially well. However, some Excel-specific formatting (gradient fills, icon sets) may not render identically in Sheets. Standard color-fill rules transfer without issues. For teams that work across both platforms, testing your formatting rules in both environments is worthwhile before distributing a shared workbook.

One practical advantage of Google Sheets for duplicate detection in team settings: multiple people can work in the same file simultaneously, and the Conditional Formatting highlights update in real time for all viewers. In Excel, shared workbooks have more limitations with real-time collaboration. If your duplicate detection workflow involves multiple team members reviewing flagged data simultaneously, Sheets may be more practical for the review phase even if the underlying data analysis happens in Excel. Export to Sheets for collaborative review, then export back to Excel for final data operations.

Test Your Excel Knowledge
Select the range you want to check โ€” exclude headers to avoid false matches
Go to Home โ†’ Conditional Formatting โ†’ Highlight Cells Rules โ†’ Duplicate Values
Choose your highlight color from the dropdown and click OK
For custom threshold (3+ occurrences), use New Rule โ†’ Use a formula: =COUNTIF($A$2:$A$100,A2)>2
For row-level highlighting, select the full table range and use: =COUNTIF($A$2:$A$100,$A2)>1
For cross-column comparison, use: =COUNTIF($B:$B,A2)>0 on column A
Lock range references with $ signs โ€” this is the most common COUNTIF formula mistake
For full-row duplicate detection, concatenate columns into a helper column and apply the built-in rule
Review highlighted cells before removing โ€” always keep a backup copy before deleting
To remove rules, go to Conditional Formatting โ†’ Clear Rules โ†’ Clear Rules from Selected Cells

Conditional Formatting โ€” including duplicate highlighting rules โ€” is tested on the Microsoft Office Specialist (MOS) Excel certification exam. Our Excel practice test covers Conditional Formatting, data validation, formulas, PivotTables, and all other core MOS exam content areas. Start with a diagnostic set to identify which Excel features need the most review before your certification exam.

Built-In Rule vs. COUNTIF Formula

Pros

  • Built-in rule: fastest setup โ€” under 30 seconds for basic duplicate highlighting
  • COUNTIF formula: precise control over threshold, range, and conditions
  • Both methods update dynamically as data changes
  • Conditional Formatting rules can be copied to other ranges or sheets
  • Multiple rules can stack to create color-coded frequency visualization

Cons

  • Built-in rule: no threshold control โ€” highlights any repeat regardless of count
  • COUNTIF formula: easy to get wrong with relative/absolute reference errors
  • Both methods highlight cells only โ€” doesn't move, sort, or delete duplicates
  • Conditional Formatting can slow down large spreadsheets (100k+ rows)
  • Rules don't distinguish first occurrence from subsequent duplicates by default

Highlighting Duplicates in Excel Questions and Answers

How do I highlight duplicates in Excel using Conditional Formatting?

Select your data range, go to Home โ†’ Conditional Formatting โ†’ Highlight Cells Rules โ†’ Duplicate Values. Choose your color from the dropdown and click OK. Excel highlights every value that appears more than once in the selection. The rule updates dynamically โ€” as you add or remove data, the highlighting adjusts automatically.

How do I highlight duplicates in Excel using a formula?

Select your range (e.g., A2:A100), go to Conditional Formatting โ†’ New Rule โ†’ Use a formula. Enter =COUNTIF($A$2:$A$100,A2)>1 and choose your format. The dollar signs on the range lock it as an absolute reference while A2 shifts relative to each cell. Change >1 to >2 for triplicates, or use =2 for exactly twice.

How do I highlight duplicate rows in Excel?

To highlight entire rows when column A has a duplicate, select the full table range (e.g., A2:D100). Add a Conditional Formatting rule with formula =COUNTIF($A$2:$A$100,$A2)>1. The $A2 reference locks the column but lets the row shift, applying the color to all cells in any row where column A has a duplicate.

Why isn't my COUNTIF Conditional Formatting working?

The most common issue is missing or incorrect $ signs in the range reference. Use $A$2:$A$100 (absolute range) with A2 (relative cell reference) โ€” not $A$2:$A$100 with $A$2 (which would only check the first cell for every row). Also verify your selection range starts at the same row as your formula's first relative reference.

How do I highlight duplicates in two columns in Excel?

To highlight values in column A that appear in column B, select A2:A100 and add a Conditional Formatting rule with formula =COUNTIF($B:$B,A2)>0. This colors every A cell whose value appears anywhere in column B. Reverse it to highlight column B cells that match column A.

How do I highlight only the second (and subsequent) occurrence of duplicates?

The built-in rule highlights all occurrences including the first. To highlight only duplicates from the second occurrence onward (preserving the first entry as unhighlighted), use a COUNTIF formula that checks only the rows above the current row: =COUNTIF($A$2:A2,A2)>1. This expands the range upward as you go down, so the first occurrence finds no match above it while subsequent occurrences do.
Remove Duplicates in Excel
4 methods to delete duplicates from your spreadsheet
Remove Duplicates Guide
Step-by-step duplicate removal walkthrough
Excel Skills Guide
Formulas, functions, and spreadsheet mastery
Excel Drop-Down Lists
Create and manage data validation lists
โ–ถ Start Quiz