How to remove duplicate values within a cell in Excel
Excel formula
=TEXTJOIN(", ",TRUE,UNIQUE(TEXTSPLIT(A2,,", ")))Split the list, keep unique items and join it back: =TEXTJOIN(", ",TRUE,UNIQUE(TEXTSPLIT(A2,,", "))).
- Result on the example
- one result per row in
B2, filled down toB6 - Works in
- Excel 2024 and Microsoft 365
- Google Sheets
- Different formula, see below
See it work
The formula is already in B2, filled down to B6. Change any input and the result updates, or edit the formula to experiment.
How it works
TEXTSPLIT turns the cell into a column of items (", " is the row delimiter), UNIQUE keeps the first copy of each, and TEXTJOIN joins them back with the same separator. Items stay in their original order.
In Google Sheets, SPLIT returns a row, and UNIQUE works on rows, so TRANSPOSE turns the items into a column first.
=TEXTJOIN(", ",TRUE,UNIQUE(TEXTSPLIT(A2,,", ")))Result"red, blue, green"
A2"red, blue, red, green, blue"The value in A2.
TEXTSPLIT(A2,,", "){5 rows × 1 col} "red", "blue", "red", "green", …TEXTSPLIT: Splits text across columns, and rows, at the delimiters you give.- text
A2"red, blue, red, green, blue" - col_delimiter
(omitted) - row_delimiter
", "
- text
UNIQUE(TEXTSPLIT(A2,,", ")){3 rows × 1 col} "red", "blue", "green"UNIQUE: Distinct rows of a range. Spills.- array
TEXTSPLIT(A2,,", "){5 rows × 1 col} "red", "blue", "red", "green", …
- array
TEXTJOIN(", ",TRUE,UNIQUE(TEXTSPLIT(A2,,", ")))"red, blue, green"TEXTJOIN: Joins text with a delimiter between items.- delimiter
", " - ignore_empty
TRUE - text1
UNIQUE(TEXTSPLIT(A2,,", ")){3 rows × 1 col} "red", "blue", "green"
- delimiter
In Google Sheets
Google Sheets needs a different formula: =JOIN(", ",UNIQUE(TRANSPOSE(SPLIT(A2,", ",FALSE)))). On the same data it gives the same result. Here it is running in Google Sheets mode.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =TEXTJOIN(", ",TRUE,SORT(UNIQUE(TEXTSPLIT(A2,,", ")))) | blue, green, red, oak, walnut, steel…Different result | Also sorts the items A to Z. "blue, green, red" instead of "red, blue, green". |
Common mistakes
- Excel's UNIQUE ignores case ("Pine" and "pine" are one item), while Google Sheets' UNIQUE is case-sensitive. Lowercase the list first if your data mixes cases.
- Inconsistent spacing ("red,blue, red") creates items that look the same but differ. Split on "," and TRIM:
UNIQUE(TRIM(TEXTSPLIT(A2,,","))).
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Remove duplicate values within a cell
B2, remove repeated items from the comma-separated list, keeping the first occurrence of each, and fill down to B6.Questions
How do I count the unique items in the cell?
Count the list: =COUNTA(UNIQUE(TEXTSPLIT(A2,,", "))).
How do I remove duplicates in a whole column instead?
Use =UNIQUE(A2:A100).
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.