Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel UNIQUE Exclude Blanks: Step-by-Step Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To get a list of unique values from an Excel range while ignoring blanks, use the UNIQUE function with a FILTER wrapper: =UNIQUE(FILTER(A2:A100, A2:A100<>"")). This returns each distinct non-blank entry once, in the order it first appears. If you are on an older Excel version without UNIQUE or FILTER, you can use a helper column with COUNTIF or a PivotTable instead. The steps below cover both the modern dynamic-array method and the fallback approaches, plus what to do when the formula returns errors or unexpected results.

What You'll Need

  • Excel for Microsoft 365, Excel 2021, or Excel for the web (for the UNIQUE and FILTER functions). Older versions can use the helper-column or PivotTable methods described later.
  • A range of data that contains both values and blank cells. The range can be a single column or multiple columns; the examples use a single column for clarity.
  • Basic familiarity with entering formulas and dragging to fill. No add-ins or macros are required.

Step-by-Step

  1. Select the cell where you want the unique list to start. Choose an empty cell with enough room below and to the right for the results to spill. For example, select cell C2 on the same sheet as your data.
  2. Enter the combined formula. Type =UNIQUE(FILTER(A2:A100, A2:A100<>"")) and press Enter. Replace A2:A100 with your actual data range. The FILTER function removes blanks first, then UNIQUE extracts the distinct values. The result will spill down automatically.
  3. Check the spill range. If the formula returns a #SPILL! error, it means something is blocking the cells where the results need to appear. Clear the cells below and to the right of the formula cell, then press Enter again.
  4. Adjust the range to match your data. If your data extends beyond row 100, change the range accordingly (for example, A2:A500). Avoid referencing entire columns like A:A in FILTER because it can slow down large workbooks; use a specific range or an Excel Table reference.
  5. Convert to a Table for automatic expansion (optional). Select your data and press Ctrl+T (Cmd+T on Mac) to create a Table. Then use the structured reference in the formula, such as . When you add new rows, the formula range updates automatically.
  6. Sort the unique list if needed. Wrap the formula in SORT: =SORT(UNIQUE(FILTER(A2:A100, A2:A100<>""))). This returns the unique non-blank values in alphabetical or numerical order.
  7. For older Excel versions without UNIQUE or FILTER, use a helper column. In a blank column next to your data (say column B), enter =IF(A2="","",IF(COUNTIF($A$2:A2,A2)=1,A2,"")) in B2 and copy down. This flags the first occurrence of each non-blank value. Then filter column B to exclude blanks and copy the visible results to a new location, or use a PivotTable as described next.
  8. Use a PivotTable as an alternative. Select your data range, go to Insert > PivotTable, and place it on a new worksheet. Drag the field containing your values into the Rows area. The PivotTable will list each unique value once and automatically ignore blanks. You can then copy the list if you need it as static values.
  9. Remove blanks from an existing unique list. If you already have a UNIQUE formula that includes a blank (because the source range contains empty cells), wrap it with FILTER as shown in step 2. Alternatively, use =FILTER(UNIQUE(A2:A100), UNIQUE(A2:A100)<>"") but note this calculates UNIQUE twice; the FILTER-inside-UNIQUE method is more efficient.
  10. Verify the results. Compare the count of unique non-blank values with a manual count or use =COUNTA(UNIQUE(FILTER(A2:A100, A2:A100<>""))) to get the number of distinct non-blank entries. Check that no blank cells appear in the output and that all expected values are present.

Common Mistakes

  • Using UNIQUE alone on a range with blanks. UNIQUE treats an empty cell as a value and will return a 0 or a blank in the list. Always pair it with FILTER to exclude blanks.
  • Forgetting to lock the range. If you copy the formula down or across, relative references may shift. Use absolute references (e.g., $A$2:$A$100) or structured Table references to keep the range fixed.
  • Including header rows in the range. If your range includes the header, the header text will appear as a unique value. Start the range from the first data row (e.g., A2).
  • Using entire-column references in FILTER. FILTER(A:A, A:A<>"") can be very slow and may return a #VALUE! error if the column contains mixed data types. Use a bounded range or a Table.
  • Expecting the formula to work in Excel 2019 or earlier. UNIQUE and FILTER are dynamic array functions available only in Microsoft 365, Excel 2021, and Excel for the web. In older versions, use the helper column or PivotTable method.
  • Ignoring the spill range. If you type the formula in a cell that has data below it, you'll get a #SPILL! error. Clear the area or move the formula to an empty region.

Tips

  • Use =UNIQUE(FILTER(range, range<>"")) as your default pattern for unique non-blank lists. It is concise and works with both text and numbers.
  • If you need to exclude cells with formulas that return empty strings (""), the FILTER condition range<>"" will also exclude those, because they evaluate to an empty string. This is usually desired.
  • To count unique non-blank values, use =COUNTA(UNIQUE(FILTER(range, range<>""))). This gives the number of distinct entries.
  • For a case-insensitive unique list, UNIQUE treats "Apple" and "apple" as different by default. If you need case-insensitive uniqueness, use a helper column with LOWER or a more complex array formula.
  • Combine with SORT and SORTBY for ordered output: =SORT(UNIQUE(FILTER(range, range<>""))).
  • If you want to paste the unique list as static values, copy the spill range and use Paste Special > Values.

Troubleshooting

  • #SPILL! error: The formula cannot expand because one or more cells in the spill range are not empty. Clear the cells or move the formula to an empty area.
  • #CALC! error: This occurs when FILTER finds no matching values (i.e., all cells are blank). If your range might be entirely blank, wrap with IFERROR: =IFERROR(UNIQUE(FILTER(range, range<>"")), "No data").
  • Formula returns a 0 or blank: Check that the FILTER condition is correctly excluding blanks. If your data contains cells with spaces (" "), they are not considered blank by <>"". Use TRIM(range)<>"" to exclude cells with only spaces: =UNIQUE(FILTER(range, TRIM(range)<>"")).
  • UNIQUE not available: If you type =UNIQUE and Excel shows #NAME?, your version does not support dynamic arrays. Use the helper column or PivotTable method.
  • Results include duplicates: UNIQUE should remove duplicates. If you see duplicates, check that your range does not contain trailing spaces or inconsistent formatting (e.g., numbers stored as text vs. numbers). Use TRIM and clean data first.
  • Performance issues: Large ranges with FILTER and UNIQUE can be slow. Limit the range to the actual data area or use a Table to keep it dynamic but bounded.

Frequently Asked Questions

Can I use UNIQUE without FILTER to exclude blanks?

No. UNIQUE alone treats blank cells as a value and will return a 0 or an empty entry in the list. You must combine it with FILTER to remove blanks.

Does this work in Excel 2019?

No. UNIQUE and FILTER are available only in Microsoft 365, Excel 2021, and Excel for the web. In Excel 2019 and earlier, use a helper column with COUNTIF or a PivotTable to get unique non-blank values.

How do I exclude cells that contain only spaces?

Use TRIM inside the FILTER condition: =UNIQUE(FILTER(range, TRIM(range)<>"")). This treats cells with only spaces as blank and excludes them.

Can I get a unique list from multiple columns?

Yes. Use =UNIQUE(FILTER(TOCOL(A2:C100), TOCOL(A2:C100)<>"")) to flatten the range into a single column and then filter out blanks. TOCOL is available in the same Excel versions as UNIQUE and FILTER.

Why does my formula return a #CALC! error?

#CALC! occurs when FILTER finds no matching values, meaning all cells in the range are blank. Wrap the formula in IFERROR to handle this gracefully.

Can I sort the unique list alphabetically?

Yes. Wrap the entire formula in SORT: =SORT(UNIQUE(FILTER(range, range<>""))). This returns the unique non-blank values in ascending order.