Highlight a Value’s 2nd, 3rd, or Nth Appearance in Google Sheets

Highlighting the Nth occurrence—such as the 2nd, 3rd, or 10th time a value appears—is very useful in Google Sheets. You might find this helpful in many real-life scenarios. For example:

  • In a customer support log, you may want to highlight the third time a customer reports an issue—a sign that something’s not resolved. This helps escalate recurring problems and prioritize follow-ups.
  • In a sales record, highlight the 10th purchase by a customer to trigger a loyalty reward or discount. It helps automate milestone tracking and improve customer retention.
  • In offices, schools, or banks, highlight the second Saturday of a given month to identify a recurring holiday.

This tutorial shows you how to highlight the Nth occurrence in Google Sheets using conditional formatting—whether your data is arranged in columns or rows.

Highlight a Value’s 2nd, 3rd, or Nth Occurrence in a Column

Let’s say you have a list of fruits in B2:B. You want to highlight, for example, the 3rd time a specific fruit appears.

Conditional formatting formula to highlight the Nth occurrence of a value in a column in Google Sheets

Steps:

  1. Specify the occurrence number in cell C2 (e.g., 3).
  2. Enter the value to highlight in cell D2 (e.g., “Apple”).
  3. Select the range B2:B.
  4. Go to Format > Conditional formatting.
  5. Under Format rules, choose Custom formula is.
  6. Enter this formula:
    =AND($B2=$D$2, COUNTIF($B$2:B2, $D$2)=$C$2)
  7. Pick a formatting style and click Done.

This will highlight the Nth occurrence (as specified in C2) of the value you entered in D2.

How the Formula Works

The formula uses a running count:

COUNTIF($B$2:B2, $D$2)

This counts how many times the value in D2 has appeared up to the current cell. If that count matches the number in C2, and the value matches D2, the cell gets highlighted.

Want to highlight the entire row instead of just the column? Just change the “Apply to range” in the sidebar to include full rows (like A2:D100).

Highlight a Value’s 2nd, 3rd, or Nth Occurrence in a Row

Most data is arranged in columns, but sometimes you might have values laid out across a row.

For example, let’s say the list is in row 2, from B2:Z2. You want to highlight the Nth occurrence of a specific item in that row.

Conditional formatting formula to highlight the Nth occurrence of a value in a row in Google Sheets
  • Specify the occurrence number in cell A6.
  • Enter the item to highlight in cell A8.

Apply This Rule:

  1. Select the range B2:Z2.
  2. Use this conditional formatting formula:
    =AND(B$2=$A$8, COUNTIF($B$2:B2, $A$8)=$A$6)

That’s how you can highlight the Nth occurrence in a row in Google Sheets.

If you want to highlight the entire column where that Nth occurrence appears (rather than just the cell in row 2), update the Apply to range in the sidebar to include all rows in those columns. For example:

Apply to range: B2:Z100

Keep the formula the same. Since the formula checks only row 2, but you’re applying formatting to full columns, only the column that contains the Nth match will be highlighted—across all rows in that column.

Final Thoughts

The ability to highlight the Nth occurrence in Google Sheets is incredibly helpful for tracking milestones, identifying repeat events, and triggering alerts or formatting based on patterns in your data.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

How to Sort Pie Slices in Google Sheets

To sort pie slices in a pie chart, you need to sort the data...

Filter Items Unique to Groups in Google Sheets

In this tutorial, we'll learn how to filter items unique to groups in Google...

Find Common Items Across Multiple Columns in Google Sheets

This tutorial explains how to find common items across multiple columns in Google Sheets....

Sort Column by Length of Text in Google Sheets

To sort a column by length of text, you can either use the QUERY...

More like this

How to Sort Pie Slices in Google Sheets

To sort pie slices in a pie chart, you need to sort the data...

Filter Items Unique to Groups in Google Sheets

In this tutorial, we'll learn how to filter items unique to groups in Google...

Find Common Items Across Multiple Columns in Google Sheets

This tutorial explains how to find common items across multiple columns in Google Sheets....

2 COMMENTS

  1. Thank you, but what if I only want to highlight (or color) the nth occurrence of all cells in a column without precising one?
    for example, when i put a condition like this : =countif(B:B,B2)>1
    it gives all duplicates.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.