Count cells containing criteria and another cell criteria but ignore duplicates

trebor1956

Board Regular
Joined
Jul 2, 2015
Messages
100
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I am trying to count cells in a range B2:B16 containing "KS*" but ignoring any duplicates if cell A2:A16 contain 1

ie. how many instances of KS* that are in zone 1. the answer should be 4 but I can't work out how to do it.

Can someone please help.


zone​
switch
1​
ks55
1​
ks65
1​
ks57
1​
ks55
1​
ks59
1​
ks55
2​
ks61
3​
ks62
2​
ks63
4​
ks64
1​
ks65
2​
ks65
4​
ks65
5​
ks65
1​
ks65
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try:

Book3
ABCDEF
1zoneswitchZoneUniqueUnique (dynamic formula)
21ks55144
31ks65
41ks57
51ks55
61ks59
71ks55
82ks61
93ks62
102ks63
114ks64
121ks65
132ks65
144ks65
155ks65
161ks65
Sheet12
Cell Formulas
RangeFormula
E2E2=SUMPRODUCT(SIGN(FREQUENCY(IF(A2:A16=D2,MATCH(B2:B16,B2:B16,0)),ROW(B2:B16)-ROW(B2)+1)))
F2F2=ROWS(UNIQUE(FILTER(B2:B16,A2:A16=D2)))
 
Upvote 0
Try:

Book3
ABCDEF
1zoneswitchZoneUniqueUnique (dynamic formula)
21ks55144
31ks65
41ks57
51ks55
61ks59
71ks55
82ks61
93ks62
102ks63
114ks64
121ks65
132ks65
144ks65
155ks65
161ks65
Sheet12
Cell Formulas
RangeFormula
E2E2=SUMPRODUCT(SIGN(FREQUENCY(IF(A2:A16=D2,MATCH(B2:B16,B2:B16,0)),ROW(B2:B16)-ROW(B2)+1)))
F2F2=ROWS(UNIQUE(FILTER(B2:B16,A2:A16=D2)))
Try:

Book3
ABCDEF
1zoneswitchZoneUniqueUnique (dynamic formula)
21ks55144
31ks65
41ks57
51ks55
61ks59
71ks55
82ks61
93ks62
102ks63
114ks64
121ks65
132ks65
144ks65
155ks65
161ks65
Sheet12
Cell Formulas
RangeFormula
E2E2=SUMPRODUCT(SIGN(FREQUENCY(IF(A2:A16=D2,MATCH(B2:B16,B2:B16,0)),ROW(B2:B16)-ROW(B2)+1)))
F2F2=ROWS(UNIQUE(FILTER(B2:B16,A2:A16=D2)))
Hi Eric,

Thank you for the solutions. I presume I can use either? I have tried them both and the first gives a result of 1 the other says "this function not valid" - any ideas?
 
Upvote 0
Book1
ABCD
1zoneswitchZoneUnique
21ks5514
31ks65
41ks57
51ks55
61ks59
71ks55
82ks61
93ks62
102ks63
114ks64
121ks65
132ks65
144ks65
155ks65
161ks65
Sheet1
Cell Formulas
RangeFormula
D2D2=SUMPRODUCT(IF($A$2:$A$16=C2,IF(LEFT($B$2:$B$16,2)="ks",1/COUNTIFS($A$2:$A$16,C2,$B$2:$B$16,"ks*",$B$2:$B$16,$B$2:$B$16),"")))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Hi Eric,

Thank you for the solutions. I presume I can use either? I have tried them both and the first gives a result of 1 the other says "this function not valid" - any ideas?
It depends on which version of Excel you're using. As Fluff mentioned, if you could update your profile, we could be a bit more targeted with our suggestions.

The first formula should work for you, but you need to enter it with Control+Shift+Enter, not just Enter. The second formula probably won't work for you since it uses functions only available in Excel 365 or Excel 2021, and the error message you're getting seems to indicate you don't have them.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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