How to make COUNTIF(S) work with arrays?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

Unless I'm missing something, it appears to me that both COUNTIF and COUNTIFS only work with ranges, i.e. continuous selections of cells. When I try to put a filtered array for the range parameter, the formulas don't accept it.

For instance, in the attached XL2BB, I'm trying to count how many cells in column B have the letter "a", but I want to filter the range based on whether column A is number or not. (I want to do this to make the ranges as small as possible because my actual data is so big with a lot of empty rows in between chunks of data.) So I'm trying to write a formula like this:

=COUNTIF(FILTER(B2:B20,ISNUMBER(A2:A20)),"a")

But after hitting ENTER, it gives me error, so I can't even input this formula. Any suggestions on how to make COUNTIF(S) work with arrays? (This same type of filtering works very well with other formulas that accept arrays in their parameters, such as INDEX, etc.)


Book1
ABC
1
2a
31c
4f
51a
61g
7
8
91o
101a
111p
12d
13b
14
15
161q
17h
181a
19a
201g
Sheet1



Thanks for any input!
 
Thanks all! Very informative. I have also seen slow-down with SUMPRODUCT with large ranges.
I have now done some testing with a large range (40,000 rows) & in fact SUMPRODUCT was about 10% faster than the FILTER suggestion.
However, the suggestion by @Phuoc in post #7 was about 85% faster than the FILTER option. So provided it does what is required - and i think it should - I would go with that for a large range.
For anything not huge though, I would use the one that you understand the best in case you have to modify it later.
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I see, that's great information; thanks for all the checking. Thanks all again for the various solutions.
 
Upvote 0

Forum statistics

Threads
1,216,372
Messages
6,130,223
Members
449,567
Latest member
ashsweety

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top