简体   繁体   中英

Excel Formula for COUNTIFS with Multiple Named Ranges

I have an equation with this structure: =SUMPRODUCT(COUNTIFS(range1,crit1,range2,crit2,range3,namedrange1,range4,namedrange2))

It works when I remove 1 of the following groupings: (range3 and namedrange1), (range4 and namedrange2), (range1 and crit1), and it works if I enter single references from either of the named ranges. I went through evaluate formula, and it returns all 0s within the SUMPRODUCT, even though looking at the data I can plainly see that it should not return 0. Removing range2 and crit2 still returns 0 (it shouldn't return 0 here either).

Namedrange1 contains 3 entries and namedrange2 contains 34 entries.

I've searched around on google, here and mrexcel and I can't seem to find a reason why this equation won't work. Any help is appreciated.

I assume that both namedrange1 and namedrange2 are of the same vector type, ie both vertical ranges or both horizontal ranges?

In order to obtain your desired total, it will be necessary to make it so that one of these two ranges is orthogonal to the other. As such, you can either set it up to this effect within your workbook, or else transpose one of the ranges in-formula, ie:

=SUM(COUNTIFS(range1,crit1,range2,crit2,range3,namedrange1,range4,TRANSPOSE(namedrange2)))

though note that this now requires committing as an array formula** .

For an explanation as to why such a transposition of one of the ranges is necessary, you might wish to read the following article:

https://excelxor.com/2014/09/28/countifs-multiple-or-criteria-for-one-or-two-criteria_ranges/

Regards

**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM