Skip to main content

How to extract unique values from multiple columns in Excel?

Author Xiaoyang Last modified
A screenshot of an Excel dataset containing multiple columns with some repeated values

If you often work with datasets spread across several columns in Excel, you may face situations where certain values are duplicated within the same column or between different columns. In many reporting or data analysis tasks, it becomes necessary to identify and extract all unique values—those that appear only once across the whole selection, regardless of where they are located. Doing this manually can be time-consuming and error-prone, especially when dealing with large datasets or complex tables. Fortunately, Excel offers a range of methods to efficiently extract these unique values.

This guide introduces several solutions you can use based on your Excel version and your preferences—such as formulas suitable for all versions, dynamic array formulas for recent versions, the use of Kutools AI Aide for straightforward results, Pivot Tables for visual consolidation, and VBA code for automated extraction in complex scenarios.


Extract unique values from multiple columns with formulas

There are times when you would like to achieve this extraction with built-in Excel functions. This section details how to do so using two approaches: an array formula suitable for all versions of Excel, and a dynamic array formula available in newer versions like Excel 365 and Excel 2021. These methods are ideal when you want a direct formula-based solution, require frequent updating as your data changes, or need to avoid external add-ins or code.

Extract unique values from multiple columns with Array formula for all Excel versions

For compatibility across all Excel versions, using an array formula lets you extract unique values from several columns—even if your Excel does not support dynamic arrays. This approach utilizes a combination of INDIRECT, TEXT, MIN, IF, COUNTIF, ROW, and COLUMN functions, making it flexible for various data structures.

Suppose your data is located in the range A2:C9. To extract the unique values starting in cell E2, use the following procedure:

1. Click cell E2 (or the first cell of your output range), and input the following array formula:

=INDIRECT(TEXT(MIN(IF(($A$2:$C$9<>"")*(COUNTIF($E$1:E1,$A$2:$C$9)=0),ROW($2:$9)*100+COLUMN($A:$C),7^8)),"R0C00"),)&""

Note: In this formula:
  • A2:C9 is the data range from which you want to extract unique values.
  • E1:E1 refers to the cells immediately above your first output cell and is necessary for tracking which entries have already been output.
  • $2:$9 are the row references of your data; $A:$C are the column references. Adjust these as needed to fit your own worksheet layout.
Don't forget to update the ranges if your actual data is in a different location.

A screenshot showing how to use an array formula to extract unique values in Excel

2. Once you have entered the formula, instead of just pressing Enter, press Ctrl + Shift + Enter together to confirm it as an array formula. When done correctly, curly brackets {} will appear around your formula in the formula bar. Then, drag the fill handle from E2 down the column. Continue dragging until blank cells appear, indicating there are no more unique values left to extract. This process ensures all unique values will be displayed in the target column.

A screenshot showing unique values extracted using the array formula in Excel

Explanation of this formula:
  1. $A$2:$C$9: Specifies the entire set of cells to examine for unique values.
  2. IF(($A$2:$C$9<>"")*(COUNTIF($E$1:E1,$A$2:$C$9)=0), ROW($2:$9)*100+COLUMN($A:$C),7^8):
    • $A$2:$C$9<>"" ensures that blank cells are ignored.
    • COUNTIF($E$1:E1,$A$2:$C$9)=0 makes sure that only new (not yet extracted) values are included.
    • If both conditions are true, the corresponding output is a calculation based on the cell's row and column to generate a unique index number.
    • If either condition is false, the formula returns a very large number (7^8) to prevent accidental selection.
  3. MIN(...): Identifies the lowest index number, effectively locating the position of the next available unique value within the data.
  4. TEXT(...,"R0C00"): Changes the index into a valid cell reference using the R1C1 style.
  5. INDIRECT(...): Converts the cell reference created above to a value from your data range.
  6. &"": Forces the formula result to be treated as text, ensuring no formatting surprises.
This method works in all Excel versions. However, it's important to use array formulas correctly (with Ctrl + Shift + Enter), or they might not produce the expected result. Additionally, with large datasets, array formulas can slow down calculation speed, so use them with moderate-sized tables for best performance.

 
Extract unique values from multiple columns with formula for Excel 365, Excel 2021, and newer versions

If you use Excel 365, Excel 2021, or a newer version, you have access to dynamic array functions, which provide a simpler and more intuitive way to extract unique values from multiple columns. The UNIQUE and TOCOL functions make it easier and faster to combine data across columns and eliminate duplicates in a single step—especially useful for those working with constantly updating or larger datasets.

To use this method, simply select a blank cell (for example, E2, or wherever you'd like the results to appear), enter this formula, and press Enter:

=UNIQUE(TOCOL(A2:C9,1))

After pressing Enter, all unique values from the range A2:C9 will spill into the cells below the formula automatically. This feature is particularly efficient—the output updates dynamically as your source data changes, saving you manual refresh steps.

A screenshot showing the UNIQUE function in Excel extracting unique values from multiple columns

Parameter explanation:
  • TOCOL(A2:C9,1): Converts your range of values from multiple columns into a single column, removing blank cells automatically.
  • UNIQUE(...): Extracts each value only once, providing a clean, de-duplicated list.
Tip: If your data set is likely to change, using this dynamic solution ensures you always have an up-to-date list of unique entries. This method is only available in Microsoft 365, 2021, and later versions—if using an older version, refer to the array formula above.
If you encounter any #SPILL! errors, check that there are no merged cells or existing data blocking the output range, as dynamic arrays need clear space below the formula cell to display all results.
 

Extract unique values from multiple columns with Kutools AI Aide

If you’d like a more streamlined approach and want to reduce manual effort, Kutools AI Aide in Kutools for Excel can help you extract unique values from multiple columns with ease. This method is especially valuable if you aren’t familiar with formulas or want to avoid the risk of formula errors. Kutools AI Aide interprets your instructions and processes the data automatically, which is ideal for both beginners and users looking for a quick solution in just a few clicks.

Note: To experience Kutools AI Aide, make sure to download and install Kutools for Excel. Kutools is a user-friendly add-in with a wide range of automation features.

After installation, click Kutools AI > AI Aide to open the "Kutools AI Aide" pane:

  1. Enter your request in the chat box, such as: "Extract unique values from the range A2:C9, ignoring blank cells, and place the results starting at E2:"
  2. Click "Send" or press Enter, then after AI analyzes the request, simply click "Execute" to run. The results will instantly appear in your worksheet, at the exact location you indicated.

Tip: This solution is very useful if your data extraction workflow varies or if you want natural language processing features. Remember to double-check the extracted list for blank cells if your original data is not perfectly consistent, as blank entries might be included or filtered based on your AI request details.

A GIF demonstrating how Kutools AI Aide extracts unique values from multiple columns in Excel

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

Extract unique values from multiple columns with Pivot Table

Pivot Tables are another convenient method for extracting unique values, particularly if you prefer working with visual tools and want to summarize or further analyze the unique items, such as counting occurrences. This approach is straightforward and doesn't require formulas. However, it requires a few steps of setup and slight data rearrangement, especially if the columns involved have different headings.

Here is a suggested process for extracting unique values using a Pivot Table:

1. Insert a new blank column immediately to the left of your data. For example, insert a new column A if your data starts at column B. This adjustment helps ensure correct range consolidation.

A screenshot showing the addition of a blank column before using a Pivot Table in Excel

2. Select any cell within your dataset, press Alt + D, then quickly press P to launch the "PivotTable and PivotChart Wizard." In the wizard's first step, select "Multiple consolidation ranges." This allows you to combine values from numerous columns into a single summarized field.

A screenshot of the PivotTable and PivotChart Wizard with 'Multiple consolidation ranges' selected

3. Click Next, then choose "Create a single page field for me." This step organizes all your data as a single group for easier unique value extraction.

A screenshot showing 'Create a single page field for me' selected in the Pivot Table Wizard

4. In the next step, select the entire data range (include the new blank column), click the Add button to bring your selection into the "All ranges" list, and click Next.

A screenshot of the Pivot Table Wizard with data range selection

5. In the wizard's final step, select where you would like to place the Pivot Table (new worksheet or existing sheet), then click Finish to generate the Pivot Table report.

A screenshot showing where to place the Pivot Table report in Excel

6. In the new Pivot Table, uncheck all fields in the "Choose fields to add to report" section to clear the default view.

A screenshot of a created Pivot Table in Excel for unique value extraction

7. Finally, drag the "Value" field to the Rows area. The Pivot Table will display all unique values from your original multi-column range, organized neatly in a single column.

A screenshot showing unique values extracted using a Pivot Table in Excel

Advantages: This method is simple and doesn't require formula knowledge, while also letting you further analyze the unique entries via built-in Pivot Table features (like counting, grouping, or filtering).
Limitations: Data needs preliminary arrangement, and if your source dataset updates, you must refresh the Pivot Table to see new unique values.

Extract unique values from multiple columns with VBA code

In cases where you need to automate extraction or handle large and irregular datasets, using VBA (Visual Basic for Applications) code can provide a quick and reusable solution. This is ideal for users with basic familiarity with the Excel VBA editor, or for recurring tasks where you want to minimize manual operations. VBA can also handle large data volumes more efficiently than array formulas.

1. Open the VBA editor by pressing Alt + F11. In the "Microsoft Visual Basic for Applications" window that appears, click Insert > Module to add a new module.

2. In the new module, paste the code below:

VBA: Extract unique values from multiple columns

Sub Uniquedata()
'Updateby Extendoffice
Dim rng As Range
Dim InputRng As Range, OutRng As Range
Set dt = CreateObject("Scripting.Dictionary")
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, Type:=8)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, Type:=8)
For Each rng In InputRng
    If rng.Value <> "" Then
        dt(rng.Value) = ""
    End If
Next
OutRng.Range("A1").Resize(dt.Count) = Application.WorksheetFunction.Transpose(dt.Keys)
End Sub

3. Press F5 to run the code. A dialog will prompt you to select the data range. Select all relevant columns (including any with blank cells).

A screenshot of the VBA prompt for selecting a data range in Excel

4. After clicking OK, another prompt asks where to output the unique values. Specify a top cell where you want the results listed (e.g., E2).

A screenshot of the VBA prompt for selecting the output cell in Excel

5. Click OK, and the macro will run automatically. All unique values will appear, starting at your specified location.

A screenshot showing unique values extracted using VBA in Excel

Tips: If your dataset contains a large number of blanks or data types, double-check the output for accidental duplicates or omissions. It's also recommended to save your workbook before running VBA, especially if you aren't experienced with macros.

Troubleshooting and practical suggestions:
  • If you receive errors like #VALUE! or #SPILL! when using formulas, check your ranges and ensure the output area is clear.
  • Always check for hidden rows or merged cells in your data range, as these may affect the correctness of your unique value extraction.
  • Array and dynamic array formulas update automatically with changes, but Advanced Filter and Pivot Table solutions may require manual refresh or re-run.
  • For recurring tasks, consider automating extraction using VBA for consistency and speed.
  • Back up your data before applying any mass extraction or automation routines, especially in complex workbooks.

More relative articles:

  • Count The Number Of Unique And Distinct Values From A List
  • Suppose you have a long list of values with some duplicate items, and you want to count how many unique values (the values that appear only once) or total distinct values exist in a column, as shown in the left screenshot. This article explains efficient methods for counting unique and distinct entries in Excel.
  • Extract Unique Values Based On Criteria In Excel
  • Suppose you want to extract only the unique names from column B based on a specific condition in column A, producing results as shown in the screenshot. This tutorial demonstrates ways to apply criteria when extracting unique values.
  • Only Allow Unique Values In Excel
  • If you want to allow only unique entries in a worksheet column and prevent duplicate values, this article introduces practical techniques to enforce uniqueness rules in Excel.
  • Sum Unique Values Based On Criteria In Excel
  • For example, you may need to sum only the unique values in an "Order" column based on names in an adjacent column, as shown in the screenshot. This article discusses approaches to combining unique and conditional calculations.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!