Can anyone please tell me how to count in a range?
For example, in a data set, how to count all the values between 3.5 and 5.6
Many Thanks.
You could use SUMPRODUCT
(substitute "range" with your actual range address)Code:=SUMPRODUCT(--(range>=3.5),--(range<=5.6))
Or you could use 2 COUNTIFs
or... written another wayCode:=COUNTIF(range,">=3.5")-COUNTIF(range,">5.6")
Of course if 3.5 and 5.6 are themselves variables you would need to adjust accordingly (the final option of the three outlined would in effect become void)Code:=SUM(COUNTIF(range,{">=3.5",">5.6"})*{1,-1})
Those using XL2007 & beyond would use COUNTIFS
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
Just to mention that you can put references instead of number (for example A1 and A2 instead of 3.4 and 5.1)
Another solution:
=SUMPRODUCT(--(ABS($D$1:$D$32-($A$1+$A$2)/2)<=($A$2-$A$1)/2))
comfirmed with ctrl+shift+enter
where A1 and A2 are references and D1:D32 is range
"Relax. What is mind? No matter. What is matter? Never mind!"
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks