Count all nonblanks in a column, but exclude duplicates and hidden rows.

Telefonstolpe

Board Regular
Joined
Sep 25, 2014
Messages
55
Hi,

I´m looking for a function that counts all nonblanks in a column, but excludes duplicates and hidden rows.
Been trying for a while to solve this problem with sumproduct- and subtotal functions, but I can't get it to work in the end. I realized it was more difficult than it seemed.

Example of what I'm trying to do:

[TABLE="class: grid, width: 100, align: left"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Apple[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Apple[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Pear[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Pear[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Pear[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Orange[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Orange[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Orange[/TD]
[/TR]
</tbody>[/TABLE]

In this example red-marked rows number 3, 4, 5 and 8 are hidden
The function I'm looking for should in this case return "2", one apple plus one orange, and thus exclude duplicates, hidden rows and blanks.

Thanks in advance!
/Chris
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try the following formula, which needs to be confirmed with CONTROL+SHIFT+ENTER...

=SUM(IF(FREQUENCY(IF(SUBTOTAL(103,OFFSET(A1:A9,ROW(A1:A9)-ROW(A1),0,1))>0,MATCH("~"&A1:A9,A1:A9&"",0)),ROW(A1:A9)-ROW(A1)+1)>0,1))

Note that rows hidden via the AutoFilter are also taken into consideration.

Hope this helps!
 
Upvote 0
Thank you very much!

Works perfectly!

It's gonna take me a while to figure out the logic behind this function :)

Thanks again!

/Chris
 
Upvote 0

Forum statistics

Threads
1,223,276
Messages
6,171,139
Members
452,381
Latest member
Nova88

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