How to Count Unique Visible Values Excluding Specific Text in Excel
Question details
The user needs to count unique visible cells in a filtered Excel table while explicitly excluding cells that contain a specific exact text value.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Working with a large, filtered dataset where a unique count of visible rows is required, but a specific string needs to be omitted from the final tally.
- Observed behavior
- Standard counting functions evaluate hidden rows or include the unwanted text, requiring complex array formulas to correctly evaluate both visibility and exclusion criteria simultaneously.
Ensure your dataset is organized without completely blank rows in the middle of your range, as blank cells can occasionally cause MATCH formulas to return errors when evaluating arrays.
Use a Complex Array Formula (Older Excel Versions)
This method utilizes a combination of FREQUENCY, SUBTOTAL, OFFSET, and MATCH to count unique visible items while ignoring your specified text string without needing helper columns.
This formula combines SUBTOTAL and OFFSET to determine row visibility. MATCH checks for unique values, and IF logic excludes the target text. Because it relies on array evaluation, it requires a specific keystroke combination in non-365 Excel versions.
Click on the cell where you want the final unique count to be displayed.
Enter the following formula, replacing 'x' with your actual text and adjusting the range (D$3:D$383) to match your dataset: =SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(D$3,ROW(D$3:D$383)-ROW(D$3),,1)),IF(D$3:D$383<>"x",MATCH("~"&D$3:D$383,D$3:D$383&"",0))),ROW(D$3:D$383)-ROW(D$3)+1),1))
Instead of pressing Enter, press Ctrl+Shift+Enter simultaneously. Excel will wrap the formula in curly braces {}, indicating it is evaluating as an array.

Use Microsoft 365 Dynamic Functions
If you are using Microsoft 365 or Excel 2021, modern dynamic array functions provide a simpler syntax to achieve the same result.
Process Complex Array Formulas Effectively with WPS Spreadsheet
WPS Office perfectly processes complex array formulas like FREQUENCY, SUBTOTAL, and MATCH, allowing you to filter and count large datasets effortlessly. Enjoy robust spreadsheet capabilities tailored for high efficiency.
- 1. Open your Excel dataset: Launch WPS Spreadsheet and open your existing .xlsx workbook containing the filtered table.
- 2. Apply the complex formula: Select an empty cell and paste the SUM(IF(FREQUENCY...)) formula, updating your range parameters.
- 3. Calculate the array: Press Ctrl+Shift+Enter. WPS Spreadsheet will perfectly evaluate the array formula and return the accurate unique visible count.

Frequently Asked Questions
Why does my array formula return 0 or a #VALUE error?
In older versions of Excel, hitting only 'Enter' breaks the array logic. You must click into the formula bar and press Ctrl+Shift+Enter together. When done correctly, curly brackets will appear around the formula.
Can I use COUNTIFS to count visible filtered cells?
No, standard COUNTIF and COUNTIFS functions evaluate all cells in a referenced range regardless of whether they are visible or hidden. You must use SUBTOTAL or AGGREGATE combined with OFFSET to specifically target visible rows.
Is there an easier way if I don't want to use complex array formulas?
Yes, you can use a helper column. Create a new column with the formula =SUBTOTAL(3, A2) and drag it down. This flags visible rows with a 1. You can then create a Pivot Table or use simpler formulas based on that new helper column to count unique items excluding 'x'.




