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.

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....

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.