Counting names based on their department

Nutmegger

New Member
Joined
Dec 14, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I have a workbook where people's names are entered into (A2:U30)
The names that are allowed to be entered are validated against a list of names in (G1:G50);
Each name has a corresponding department in (H1:H50); There are 4 different departments, so each person belongs to 1 of the 4 departments.

I am looking for a formula that will give me a count of how many people entered in (A2:U30) represent each of the 4 departments.
In other words, I want to get 4 formulas in 4 cells showing something like this:

Accounting: 5
Sales: 12
Service: 20
HR: 8

I hope someone can help - thank you in advance!
 
There's probably a more elegant solution than this, but if you're OK using a helper column (I've used column C here but it could be anywhere there's a clear column, and you can hide it if you want) then the following seems to work for what you want. I note you have 365 so hopefully the TOCOL() function is available to you. Enter the VLOOKUP/TOCOL formula into cell C6, and then a straightforward COUNTIF() referencing the spill range in B6:B9.

count.xlsx
ABCDEFGHIJKLMN
1SunMonTueWedThurFriSatNamesDepartment
2Alfonso TorresAccounting
3I would like to automate this part:Arabella VaughanHR
4Beckett FergusonHR
5Representation by deptNumbersCharlee BlackwellBroderick GalvanService
6HR8HRElise BarryBrynn ScottHR
7Accounting6AccountingCarly NobleTalent
8Sales8ServiceCarolyn IbarraService
9Service5SalesCarolyn IbarraCharlee BlackwellHR
10HRCristian HunterHR
11SalesHayley AveryArabella VaughanYahir BenderDamion RushAccounting
12HRMakayla VazquezJake DickersonCristian HunterDemarion MorganHR
13AccountingGavin PotterShawn OwensElise BarryAccounting
14HRIsla VanceJoselyn RiosEsmeralda OrrService
15ServiceHayley AveryDemarion MorganDemarion MorganGavin PotterService
16AccountingKayden LeonJaylin McphersonGeovanni AllisonSales
17ServiceKatie YatesWade MullenHayden CoffeySales
18TalentScarlett WeaverHayley AverySales
19SalesPeyton HarveyHazel CaseyAccounting
20HRIsla VanceService
21HRBroderick GalvanJadyn GoldenHR
22ServiceGeovanni AllisonJake DickersonAccounting
23AccountingHazel CaseyJavier BishopService
24SalesMatias RichardJayda SweeneyHR
25SalesJohnathan ShepardJaylin McphersonAccounting
26AccountingCharlee BlackwellJohnathan ShepardHR
27SalesJoselyn RiosTalent
28ServiceKaitlin UnderwoodHR
29SalesKatie YatesSales
30AccountingKayden LeonService
31SalesKeith FinleyService
32HRMaggie OnealHR
33HRMakayla VazquezHR
34Marlon McmahonHR
35Matias RichardSales
36Natalia MejiaService
37Peyton HarveySales
38Reina DavidsonAccounting
39Rory MorrowSales
40Ryder HoltHR
41Sanai MataHR
42Scarlett WeaverAccounting
43Shawn OwensAccounting
44Shelby BurnettSales
45Talon AustinSales
46Terry MolinaService
47Thomas SuttonAccounting
48Tomas LiuSales
49Ty McintyreHR
50Wade MullenSales
51Yahir BenderSales
52
Sheet1
Cell Formulas
RangeFormula
C6:C33C6=VLOOKUP(TOCOL($D$2:$J$36,1),$M$2:$N$51,2,FALSE)
B6:B9B6=COUNTIF($C$6#,A6)
Dynamic array formulas.
Sigh, a helper column wouldn't work, because I am trying to count the names from each department in the D2:N30 array of names, where a name from any department could be in any cell in that array..
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
That formula works for me. If you type =to into a cell, do you get 3 possible options, or just 1?
If I type =to into B6, all I get is the "Today" formula suggestion...
Also showing screenshots where the =SUM(COUNTIFS(M:M,TOCOL($D$2:$J$30,1),N:N,A6)) formula is in that cell, shows no errors, but still calculates as a "0":
 

Attachments

  • 2022-12-16_14-38-01.jpg
    2022-12-16_14-38-01.jpg
    201.9 KB · Views: 5
Upvote 0
That formula works for me. If you type =to into a cell, do you get 3 possible options, or just 1?
I see what you mean... if I type =to into a cell, I don't get TOCOL as a suggested formula.
Why wouldn't I have it?
My excel is Windows 64-bit based:

Microsoft® Excel® for Microsoft 365 MSO (Version 2202 Build 16.0.14931.20806) 64-bit
 
Upvote 0
Ok, you may be on the semi annual channel which doesn't have that function yet.
Try
Excel Formula:
=LET(Data,$D$2:$J$30,r,ROWS(Data),s,SEQUENCE(r*COLUMNS(Data),,0),x,INDEX(Data,MOD(s,r)+1,INT(s/r)+1),SUM(COUNTIFS(M:M,FILTER(x,x<>""),N:N,A6)))
 
Upvote 0
Solution
Ok, you may be on the semi annual channel which doesn't have that function yet.
Try
Excel Formula:
=LET(Data,$D$2:$J$30,r,ROWS(Data),s,SEQUENCE(r*COLUMNS(Data),,0),x,INDEX(Data,MOD(s,r)+1,INT(s/r)+1),SUM(COUNTIFS(M:M,FILTER(x,x<>""),N:N,A6)))
You are a genius. Thank you, thank you, thank you.
A much longer formula, but it sure works. Can't wait for the TOCOL to arrive.
I really appreciate your help!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

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