# How to remove duplicate values within a cell in Excel

Split the list, keep unique items and join it back: =TEXTJOIN(", ",TRUE,UNIQUE(TEXTSPLIT(A2,,", "))).

**Excel:** `=TEXTJOIN(", ",TRUE,UNIQUE(TEXTSPLIT(A2,,", ")))` (Excel 2024 and Microsoft 365)

**Google Sheets:** `=JOIN(", ",UNIQUE(TRANSPOSE(SPLIT(A2,", ",FALSE))))`

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Tags | Unique tags |
| red, blue, red, green, blue |  |
| oak, oak, walnut |  |
| steel |  |
| pine, maple, pine, cedar |  |
| brass, steel, brass, brass |  |

Formula in B2, filled to B6: `=TEXTJOIN(", ",TRUE,UNIQUE(TEXTSPLIT(A2,,", ")))`

Result: red, blue, green; oak, walnut; steel; pine, maple, cedar; brass, steel

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

## Other ways

- `=TEXTJOIN(", ",TRUE,SORT(UNIQUE(TEXTSPLIT(A2,,", "))))`: 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,,",")))`.

## 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)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/remove-duplicates-within-a-cell
