count filtered unique text values

scoobyblue

Active Member
Joined
Jun 30, 2004
Messages
380
I have a spreadsheet with a list of headings down column 'B'. Following formula calculates the number of unique text values; =SUMPRODUCT(1/COUNTIF(B6:B192,B6:B192))

This produces a result of '10', but when it is filtered and showing less visible unique text values it still shows '10'. How can my formula adjust to show number of visible unique text values after applying a filter?

Also, if the range in the formula can be extended to accommodate future additions to the column this would be useful. At present the range has to end at the last entry 'B192', otherwise the result is ♯DIV/0!. So when additions to column are input I have to keep extending the range in the formula.

Many thanks for your help.
Scoobyblue
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I have a spreadsheet with a list of headings down column 'B'. Following formula calculates the number of unique text values; =SUMPRODUCT(1/COUNTIF(B6:B192,B6:B192))

This produces a result of '10', but when it is filtered and showing less visible unique text values it still shows '10'. How can my formula adjust to show number of visible unique text values after applying a filter?

Also, if the range in the formula can be extended to accommodate future additions to the column this would be useful. At present the range has to end at the last entry 'B192', otherwise the result is ♯DIV/0!. So when additions to column are input I have to keep extending the range in the formula.

Many thanks for your help.
Scoobyblue
Control+shift+enter, not just enter:
Code:
=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(B6,ROW(B6:B192)-ROW(B6),,1)),
    IF(B6:B192<>"",MATCH("~"&B6:B192,B6:B192&"",0))),
     ROW(B6:B192)-ROW(B6)+1),1))

The "~"& and &"" bits can be removed from the formula if no special chars like < occur around the entries of interest.
 
Upvote 0
Thanks - was in a rush and didn't spot your text above saying about 'ctrl+shift+enter'. Many Thanks works perfectly.
 
Upvote 0

Forum statistics

Threads
1,224,547
Messages
6,179,436
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