How to Fix COUNTIF Value Error in Dynamic Array Formulas
Question details
The user is attempting to use the COUNTIF function inside a dynamic array formula (such as LET) but receives a #VALUE! error instead of the expected count.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Passing an in-memory dynamic array (e.g., generated by INDEX, FILTER, or LET) as the first argument to the COUNTIF function.
- Observed behavior
- The COUNTIF function fails and returns a #VALUE! error because it strictly requires a physical worksheet range and cannot process in-memory arrays.
Review your formula to confirm whether the first argument of your COUNTIF function is pointing to an actual cell range (like A1:A10) or an in-memory array created by another function.
Use Array-Compatible Alternative Functions
Replace the COUNTIF function with modern, array-compatible formulas like SUM with boolean logic, FILTER, or BYROW to perform the count.
Functions like COUNTIF, SUMIF, and their plural counterparts are hardcoded to accept only direct range references. They cannot read virtual arrays stored in memory. To work around this limitation, you can mimic COUNTIF's behavior using functions that naturally handle arrays.
Locate the portion of your dynamic array or LET formula that generates the array you want to count (for example, a variable defined in LET like 'my_array').
Instead of writing COUNTIF(my_array, "target"), convert the array into a series of TRUE/FALSE results and add them up. Write: SUM(--(my_array="target")). The double negative (--) converts TRUE to 1 and FALSE to 0, successfully counting the matches.
For more complex scenarios, utilize functions like FILTER or XMATCH. For example, you can count rows by wrapping a FILTER function inside a ROWS function: ROWS(FILTER(my_array, my_array="target")).

Output Intermediate Results to a Worksheet Range
Extract the dynamic array to actual spreadsheet cells so that the COUNTIF function can read a physical range.
Process Dynamic Arrays Seamlessly with WPS Spreadsheet
WPS Office Spreadsheet provides complete support for modern dynamic array formulas, including LET, FILTER, UNIQUE, and XMATCH. It allows you to build complex in-memory calculations and bypass legacy formula limitations easily.
- 1. Download and Install WPS Office: Download WPS Office for free from the official website and complete the quick installation.
- 2. Open Your Spreadsheet: Launch WPS Spreadsheet and open your existing file containing the problematic formula.
- 3. Apply Modern Formulas: Replace the legacy COUNTIF setup with a natively supported array function like SUM(--()) or BYROW. WPS will instantly process the in-memory array without returning a value error.

Frequently Asked Questions
Why exactly does COUNTIF throw a #VALUE! error when used with LET?
The COUNTIF function was programmed by design to require a direct physical cell range (like A1:A20). When you use functions like LET, FILTER, or INDEX to generate data, the result is an 'in-memory' virtual array. Since COUNTIF expects a physical location rather than virtual data, it fails and returns a #VALUE! error.
Does COUNTIFS have the same limitation as COUNTIF?
Yes. COUNTIFS, SUMIF, SUMIFS, AVERAGEIF, and AVERAGEIFS all share the same structural limitation. None of these functions can accept an in-memory dynamic array as their criteria range.
What does the '#' symbol mean in a dynamic array reference?
The '#' symbol is the spilled range operator. When a dynamic array formula outputs multiple values starting from a single cell (e.g., A1), adding '#' (as in A1#) tells the spreadsheet to reference the entire dynamic block of spilled cells, making it a valid, physical range that COUNTIF can read.
Is it better to use a helper column or change the formula?
It is generally better to change the formula using alternative functions like SUM with boolean operators or FILTER. This avoids cluttering your worksheet with helper columns, keeps all calculation logic centralized, and reduces the risk of accidentally overwriting spilled data.




