Data Filter - count countries selected by filter

martiano

New Member
Joined
Oct 30, 2010
Messages
11
I have table for example like this and Im using function Subtotal to count all countries what are selected by filter.

111.bmp





I will for example choose by filter only countries "Asia" and "Europe".

112.bmp



And here is the result, what is ok.

113.bmp





My quesion is:

I want to count not only Total countries selected by filter, but count all countries on every continent selected by filter.
so the resualt should by in this example:
Total countries: 13
Africa: 0
America: 0
Asia: 10
Europe:3

114.bmp


What function or functions do I need to use to get this result? Thank you
 
Last edited:
You can count the individual countries with this short UDF:
Code:
Function vis_countif(rng As Range, crit As Variant) As Long
    Dim i As Long, cel As Range
 
    For Each cel In rng
        If cel = crit And Not cel.EntireRow.Hidden Then i = i + 1
    Next cel
 
    vis_countif = i
End Function
 
Upvote 0

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,224,551
Messages
6,179,480
Members
452,915
Latest member
hannnahheileen

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