logo
search
Function Problems

How to Combine Unique Values from Multiple Cells with Commas in Excel

Phi Hung VoPhi Hung Vo Oct 13, 2026 872 views

Question details

The user needs to merge values from multiple cells into one single cell, separate them with commas, and automatically remove any duplicate numbers or text.

How to Combine Unique Values from Multiple Cells with Commas in Excel
Product
Excel
Device & OS
not provided
Scenario
Consolidating lists or arrays of data that contain duplicate entries into a clean, comma-separated text string within a single cell.
Observed behavior
Users require a formula that accurately separates items with a comma, ignores empty cells, and outputs only the unique values from the referenced range.
Before you start

Ensure your spreadsheet software supports dynamic array functions. The UNIQUE function is available in Microsoft 365, Excel 2021, and newer versions, as well as modern alternatives like WPS Spreadsheet.

Solution 1Recommended

Use TEXTJOIN and UNIQUE Functions

Combine the TEXTJOIN function with the UNIQUE function to automatically filter duplicates and merge the remaining values with a comma delimiter.

This method nests the UNIQUE function inside TEXTJOIN. The UNIQUE function first extracts a list of distinct values from your specified range, and then TEXTJOIN merges them together using your chosen delimiter (a comma and a space).

1
Select the destination cell

Click on the empty cell where you want the final comma-separated text to be displayed.

2
Enter the formula for a vertical range

If your data is stored in a column (e.g., A1 to A10), type the following formula: =TEXTJOIN(", ", TRUE, UNIQUE(A1:A10))

3
Enter the formula for a horizontal range

If your data is stored across a row (e.g., A1 to C1), type the following formula: =TEXTJOIN(", ", TRUE, UNIQUE(A1:C1))

4
Apply the formula

Press the Enter key. Carefully check that all parentheses and commas are placed correctly to prevent formula syntax errors.

Use TEXTJOIN and UNIQUE Functions
Handling Empty Cells: The 'TRUE' argument in the TEXTJOIN function tells Excel to ignore empty cells in your range, preventing awkward double commas in your final result.
Advanced Spreadsheet Functions

Easily Combine Unique Cell Values in WPS Spreadsheet

WPS Spreadsheet fully supports advanced dynamic array functions like TEXTJOIN and UNIQUE, allowing you to seamlessly extract and merge data without complicated workarounds or macros.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the file containing the data you want to merge.
  2. 2. Select the target cell: Click on the empty cell where you want the combined list to appear.
  3. 3. Apply the nested formula: Enter =TEXTJOIN(", ", TRUE, UNIQUE(A1:A10)) and press Enter to instantly view your comma-separated unique values.
Fully compatible with Microsoft Excel formulas, including TEXTJOIN and UNIQUE.Supports modern dynamic array processing for faster data consolidation.A free, lightweight, and user-friendly alternative to complex spreadsheet processing.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula result in a #NAME? error?

The #NAME? error usually occurs if your version of Excel does not support the UNIQUE function (e.g., Excel 2019 or older). You need a version that supports dynamic arrays, such as Microsoft 365, Excel 2021, or WPS Office.

Why is the formula not working or returning a syntax error message?

Syntax errors often happen due to a missing comma between the function arguments. Double-check your formula to ensure it looks exactly like =TEXTJOIN(", ", TRUE, UNIQUE(A1:A10)), paying close attention to the commas separating the delimiter, the ignore_empty argument, and the UNIQUE function.

Will this formula work if my numbers are stored as text?

Yes. If your numbers are stored as text, the UNIQUE function will still evaluate and filter them accurately, and TEXTJOIN will successfully combine them, provided the cells contain the intended exact values.