Count unique text in range

Nick70

Active Member
Joined
Aug 20, 2013
Messages
306
Office Version
  1. 365
Platform
  1. Windows
Hi,

I would like to count all cells which contain text in a specific range excluding if text is "not available".

So for example if in sheet1 range(B4:B100) we have text: 'Pear', 'Apple', 'Cherry' and 'not available' multiple times then the count should return 3 no matter how many cells have text 'Pear', 'Apple', 'Cherry' or 'not available'.

Considering we need to exclude duplicates I think we would need VBA as opposed to COUNTIF function.

Thanks,
Nix
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
as you have 365 version
=COUNTA(UNIQUE(FILTER(B4:B100,(B4:B100<>"not available")*(B4:B100<>""))))

Book9
ABCD
1
2
3
4pear5
5pear
6apple
7apple
8apple
9fred
10harry
11cherry
12harry
13not available
14pear
15pear
16apple
17apple
18apple
19fred
20harry
21cherry
22harry
23not available
24pear
25pear
26apple
27apple
28apple
29fred
30harry
31cherry
32harry
33not available
34
Sheet1
Cell Formulas
RangeFormula
D4D4=COUNTA(UNIQUE(FILTER(B4:B100,(B4:B100<>"not available")*(B4:B100<>""))))
 
Upvote 0
Solution
Here is an idea:
Book1
BCD
4Pear3
5Apple
6Cherry
7not available
8Pear
9Apple
10Cherry
11not available
12Pear
13Apple
14Cherry
15not available
16Pear
17Apple
18Cherry
19not available
20Pear
21Apple
22Cherry
23not available
24Pear
25Apple
26Cherry
27not available
28Pear
29Apple
30Cherry
31not available
32Pear
33Apple
34Cherry
35not available
36Pear
37Apple
38Cherry
39not available
40Pear
41Apple
42Cherry
43not available
44Pear
45Apple
46Cherry
47not available
48Pear
49Apple
50Cherry
51not available
52Pear
53Apple
54Cherry
55not available
56Pear
57Apple
58Cherry
59not available
60Pear
61Apple
62Cherry
63not available
64Pear
65Apple
66Cherry
67not available
68Pear
69Apple
70Cherry
71not available
72Pear
73Apple
74Cherry
75not available
76Pear
77Apple
78Cherry
79not available
80Pear
81Apple
82Cherry
83not available
84Pear
85Apple
86Cherry
87not available
88Pear
89Apple
90Cherry
91not available
92Pear
93Apple
94Cherry
95not available
96Pear
97Apple
98Cherry
99not available
100Pear
Sheet1
Cell Formulas
RangeFormula
D4D4=LET(r,TOCOL(B4:B100,1),ROWS(UNIQUE(FILTER(r,r<>"not available"))))
 
Last edited:
Upvote 0
Try this...
Book1
B
33
4pear
5apple
6cherry
7not available
8pear
9pear
10pear
11apple
12cherry
13not available
14cherry
15not available
16pear
17apple
18cherry
19not available
Sheet3
Cell Formulas
RangeFormula
B3B3=LET(rng,B4:B19,uniq,UNIQUE(rng),COUNTA(FILTER(uniq,uniq<>"not available")))

Hope that helps,

Doug
 
Upvote 0
Thanks to all.

=COUNTA(UNIQUE(FILTER(B4:B100,(B4:B100<>"not available")*(B4:B100<>"")))) works fine I get 2

=LET(r,TOCOL(B4:B100,1),ROWS(UNIQUE(FILTER(r,r<>"not available")))) I get #NAME

=LET(rng,B4:B19,uniq,UNIQUE(rng),COUNTA(FILTER(uniq,uniq<>"not available"))) I get 3 as result instead of 2

Nic :)
 
Upvote 0
you are welcome
I suspect the
=LET(rng,B4:B100,uniq,UNIQUE(rng),COUNTA(FILTER(uniq,uniq<>"not available"))) I get 3 as result instead of 2
may also see blank cells in the range as a unique value - hence 3
=LET(rng,B4:B100,uniq,UNIQUE(rng),COUNTA(FILTER(uniq,(uniq<>"not available")*(uniq<>""))))

Book9
ABCDEF
1
2
3
4pear55
5pear
6apple
7apple
8apple
9fred
10harry
11cherry
12harry
13not available
14pear
15pear
16apple
17apple
18apple
19fred
20harry
21cherry
22harry
23not available
24pear
25pear
26apple
27apple
28apple
29fred
30harry
31cherry
32harry
33not available
34
35
Sheet1
Cell Formulas
RangeFormula
D4D4=COUNTA(UNIQUE(FILTER(B4:B100,(B4:B100<>"not available")*(B4:B100<>""))))
E4E4=LET(rng,B4:B100,uniq,UNIQUE(rng),COUNTA(FILTER(uniq,(uniq<>"not available")*(uniq<>""))))
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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