Using COUNTIF on table but not counting correctly??

SNA400

Board Regular
Joined
Nov 5, 2010
Messages
52
HI All

Please bear with me on the description - a bit long winded.

I have 5 tables for the different groups in our company which we use to track holidays and I am using COUNTIF to reference the persons name on each table to tally number of days each person has off.
The issue I am having is the formula is not counting those cells where there are two names in the cell for days where two people are off.

(COUNTIF('Team Leaders'!$B$2:$M$33,M2) where M2 is the employee name and B2:M33 are the calendar cell references - the same on each table

Two names in the cell are set as "EmployeeA/EmployeeB"

I have tried using a generic to see if it will work but still no joy

Is there some way to count these or separate them within the cell to allow them to count correctly?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Maybe with wildcards:
Excel Formula:
=(COUNTIF('Team Leaders'!$B$2:$M$33,"*" & M2 & "*")
 
Upvote 0
Maybe with wildcards:
Excel Formula:
=(COUNTIF('Team Leaders'!$B$2:$M$33,"*" & M2 & "*")
I would be wary of that as it could be that a short name is also part of a longer name as in my sample below. That formula returns 5 for Fred when it should only be 3.

@SNA400
I suggest that you update your Account details (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’)

Possibly this?

22 12 15.xlsm
BCD
2Fred
3TomFred/Tom
4Tom/Alfred
5AlfredFred/Alfred/Ken
6Tom
7
Team Leaders


22 12 15.xlsm
MN
1NameCount
2Fred3
3Alfred3
4Tom4
5Ken1
Count
Cell Formulas
RangeFormula
N2:N5N2=COUNT(SEARCH("/"&M2&"/","/"&'Team Leaders'!B$2:M$33&"/"))
 
Upvote 0
I would be wary of that as it could be that a short name

I made the assumption that the OP would understand that using a short name for a function like this would cause a problem, even if the names were in different cells. Personally i would be looking to restructure the spreadsheet so that each cell would not take more than one entry - this would aid analysis at a later date.
 
Upvote 0
Hi both - sorry, I used the wrong terminology - I said generic instead of wildcard so I was aware of the issue :)

I will give your idea a try Peter and if it works I'll owe you a drink
 
Upvote 0
I will give your idea a try Peter
Hope it works for you. .. but please don't forget this:
@SNA400
I suggest that you update your Account details (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

Forum statistics

Threads
1,224,828
Messages
6,181,212
Members
453,023
Latest member
alabaz

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