Count If Question, is it possible...

JayB

New Member
Joined
Mar 21, 2011
Messages
14
Hey Everyone :),

I have a column with one or two letter codes. Sometimes, this column has multiple codes separated by a "/". For example: AB, A, CA/AB, AB/DD/AD etc. There are a finite number of different codes, about 20. I want to be able to add up the number of times each code is present on that column, regardless of whether it's all alone or with other codes included. Can someone help me?

Example:

Code:
AB
DD/AB
AC
DD
DD/AC/AB
AB/AC
DD
etc...

I would like to count each code:

AB - 4
AC - 3
DD - 4
etc
 
Thanks, that helps quite a bit. My other problem with this is I'm needing to count the number of times a two letter code is present. I was thinking that I could count the "/" and add one. Example: AB/CC/DI would count two "/" and add one. Then when there was just a two letter code, count that as one. I don't know, that seems like a really complicated way to go about it, just a thought I had. Any help with this would be great.
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Thanks, that helps quite a bit. My other problem with this is I'm needing to count the number of times a two letter code is present. I was thinking that I could count the "/" and add one. Example: AB/CC/DI would count two "/" and add one. Then when there was just a two letter code, count that as one. I don't know, that seems like a really complicated way to go about it, just a thought I had. Any help with this would be great.
Using a helper column...

Assuming your data starts in cell A2.

Enter this formula in B2 and copy down as needed:

=LEN(A2)-LEN(SUBSTITUTE(A2,"/",""))+1

Then, you can get the sum total of column B.

=SUM(B:B)

Assumes no empty cells in column A and that none of the entries will begin or terminate with the /. Like this:

/AB/AC/
 
Upvote 0
If you want a single formula...

Based on the same assumptions as noted in my other reply...

Array entered**:

=SUM(IF(ISNUMBER(FIND("/",A2:A8)),LEN(A2:A8)-LEN(SUBSTITUTE(A2:A8,"/",""))+1,1))

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.
 
Upvote 0
So I tried the above formula (T. Valko's), and I use ctrl+shift+enter, but my result is the word TRUE. What am I doing wrong?
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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