Count Case Sensitive text

BradleyS

Active Member
Joined
Oct 28, 2006
Messages
351
Office Version
  1. 2010
Platform
  1. Windows
I have the following formula: =SUMPRODUCT(--(COUNTIFS(DATAID,A2,CODE,"745D4*")))
This works OK, but the CODE needs to be case sensitive, so that it doesn't count 745d4

The criteria is a list of codes and ids on another sheet. There are hundreds of different codes
DATAID is the DNR for the IDs, and CODE is the DNR for the Codes
IDCode
1745d400
1745D400
1745D411
242K..00

On another sheet I need to count up the codes, for each ID
idCount of 745D4Count of 42K
120
201

I also need to include multiple codes in a count which I use: =SUMPRODUCT(--(COUNTIFS(DATAID,A2,CODE,{"745D4*","22a*"})))
However, this also needs to be case sensative, so that 22A is not counted.

How do I set the formulas so that they only count the correct case text?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
This link will show you how to do Case Sensitive Counts.
 
Upvote 0
This link will show you how to do Case Sensitive Counts.
I've seen that and tried it, but EXACT means that I can't use and asterisk wildcard, plus I couldn't combine it into a formula so that it only counted the items against each ID.
 
Upvote 0
I've seen that and tried it, but EXACT means that I can't use and asterisk wildcard, plus I couldn't combine it into a formula so that it only counted the items against each ID.
Yeah, you are trying to incorporate two opposing things, here:
- Case Sensitive, which means EXACT
- Wildcards, which means approximate

Trying to do both at the same time is tricky, because they are polar opposites, as far as logic goes.

The only thing I can think of is to incorporate the use of a helper column to pull off the piece you want to match, i.e. the first 5 digits in that one example ("745D4"). Then you could use that in your COUNTIFS without the wildcard. But if it is not always the first 5 digits (or some standard like that), I am not sure how you would accomplish it.
 
Upvote 0
How about:
=SUMPRODUCT(--(DATAID=1),(EXACT(LEFT(CODE,4),"745D")+(EXACT(LEFT(CODE,3),"22a"))))
 
Upvote 0
Solution
How about:
=SUMPRODUCT(--(DATAID=1),(EXACT(LEFT(CODE,4),"745D")+(EXACT(LEFT(CODE,3),"22a"))))
This does work. Thank you.
I was trying to use FIND which is case sensitive, but was unable to find a way to use it.
 
Upvote 0
How about:
=SUMPRODUCT(--(DATAID=1),(EXACT(LEFT(CODE,4),"745D")+(EXACT(LEFT(CODE,3),"22a"))))
This doesn't seem to be able to produce a count when using a single code search
i.e. =SUMPRODUCT(--(DATAID=A2),EXACT(LEFT(CODE,4),"745D"))

What am I missing?
 
Upvote 0
Use:

Excel Formula:
=SUMPRODUCT(--(DATAID=A2),--(EXACT(LEFT(CODE,4),"745D")))

or:

Excel Formula:
=SUMPRODUCT((DATAID=A2)*(EXACT(LEFT(CODE,4),"745D")))

In your multi-criteria one, the + was taking care of coercing the True/False values to 1/0 respectively. Either using -- or * will achieve the same thing.
 
Upvote 0
Use:

Excel Formula:
=SUMPRODUCT(--(DATAID=A2),--(EXACT(LEFT(CODE,4),"745D")))

or:

Excel Formula:
=SUMPRODUCT((DATAID=A2)*(EXACT(LEFT(CODE,4),"745D")))

In your multi-criteria one, the + was taking care of coercing the True/False values to 1/0 respectively. Either using -- or * will achieve the same thing.
Thank you
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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