Find Duplicates in New Lines Inside Cells in Google Sheets

If you’re trying to find duplicates in new lines inside cells in Google Sheets, the following formula can help:

=LET(txt, ARRAYFORMULA(TRIM(SPLIT(A1, CHAR(10)))), UNIQUE(FILTER(txt, COUNTIF(txt, txt)>1), TRUE))

Just replace A1 with the target cell reference.

Example: Find Duplicates in Multiline Cells in Google Sheets

Let’s say you have the following text in cell A1 (each item entered on a new line using Alt+Enter):

Apple
Banana
Orange
Apple
Grapes

Use this formula in cell B1:

=LET(txt, ARRAYFORMULA(TRIM(SPLIT(A1, CHAR(10)))), UNIQUE(FILTER(txt, COUNTIF(txt, txt)>1), TRUE))

Result: It will return "Apple" – the duplicate entry in that cell.

What If There Are Multiple Duplicates?

If cell A2 contains:

Apple
Banana
Orange
Apple
Grapes
Grapes

The formula in cell B2 will return "Apple" and "Grapes" across B2 and C2:

=LET(txt, ARRAYFORMULA(TRIM(SPLIT(A2, CHAR(10)))), UNIQUE(FILTER(txt, COUNTIF(txt, txt)>1), TRUE))

Formula Explanation

The formula works by breaking the cell content into separate lines and checking for repeated values:

  • ARRAYFORMULA(TRIM(SPLIT(A1, CHAR(10)))) – splits the multiline content by line breaks and trims any spaces.
  • COUNTIF(txt, txt)>1 – identifies repeated values.
  • FILTER(...) – filters only those values that occur more than once.
  • UNIQUE(..., TRUE) – ensures each duplicate is listed only once.

This is a handy way to find duplicates in multiline cells in Google Sheets, especially when entries are separated by line breaks within the same cell.

Highlight Cells Containing Duplicates

Google Sheets doesn’t allow you to highlight individual values inside a cell, but you can highlight the entire cell if it contains duplicates.

Example showing highlighted duplicates in multiline cells in Google Sheets

Here’s how:

Use the modified formula to return the count of duplicate values:

=LET(txt, ARRAYFORMULA(TRIM(SPLIT(A1, CHAR(10)))), COUNTA(IFNA(UNIQUE(FILTER(txt, COUNTIF(txt, txt)>1), TRUE))))
  • IFNA(...) suppresses errors when there are no duplicates.
  • COUNTA(...) returns the number of duplicate entries found.

Apply Conditional Formatting

  1. Select your range (e.g., A1:A).
  2. Click Format > Conditional Formatting.
  3. Under Format Rules, choose Custom formula is.
  4. Enter the above formula.
  5. Choose your preferred formatting style.
  6. Click Done.

Now, any cell containing duplicate values in new lines will be highlighted. This approach provides a visual way to find duplicates in new lines inside cells in Google Sheets.

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.

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

Use XLOOKUP in a Structured Table in Google Sheets (Single and Multiple Conditions)

This tutorial is for users who want to apply XLOOKUP inside a structured table...

Reset SCAN by Another Column in Google Sheets and Excel

Resetting SCAN function results based on values in another column is a topic of...

How to Get the Fastest Time for Each Person in Google Sheets

Whether you’re tracking race results, event times, or any other timed activities, finding the...

More like this

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

Use XLOOKUP in a Structured Table in Google Sheets (Single and Multiple Conditions)

This tutorial is for users who want to apply XLOOKUP inside a structured table...

How to Get the Fastest Time for Each Person in Google Sheets

Whether you’re tracking race results, event times, or any other timed activities, finding the...

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.