Sum Values in Table Against Value in 2nd Table

Grasor

Board Regular
Joined
May 16, 2014
Messages
123
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

This week IT updated our office suite to 365 but defaulted the Macro security settings from "with notification" to "require digital signature". However, we can't seem to get digital signatures to work and now are macros are all useless. That's a separate matter I'm trying to work out with enterprise IT, I'm hopeful they see the error of their ways and return to the original setting that's worked seemingly fine for at least my past 15 years working on these.

For now, I'm trying to address an issue that would be handily resolved with a custom VBA function.

I have running table of status codes assigned to personnel which describe their status on a particular day. My manager wants to quickly determine which codes are considered "Present" or "Absent" by referencing a 2nd table of values. He wants to be able to adjust which codes are considered "Present" or "Absent" by adjusting the reference in the 2nd table in case policy changes the outcome for each individual code.

What I have done so far is use
Excel Formula:
=SUM(COUNTIF(Range,{"Code1","Code2","Code3","etc"}))
to get the numbers I should get, but I can't figure out how to change the arrayed portion to a table reference.

Any ideas?

Example.xlsx
ABCDEFGHIJ
4Names3/1/20223/2/20223/3/20223/4/20223/5/2022Reference Table
5Person 1PCCPPPPRESENT
6Person 2EPPPPEPRESENT
7Person 3KMMPPKPRESENT
8Person 4CUUUCCPRESENT
9MABSENT
10Count Present42234UABSENT
11Count Absent02210
12Total44444
Example Sheet
Cell Formulas
RangeFormula
B10:F10B10=SUM(COUNTIF(B5:B8,{"P","E","K","C"}))
B11:F11B11=SUM(COUNTIF(B5:B8,{"M","U"}))
B12:F12B12=SUM(B10:B11)
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try

B10 copied across
=SUMPRODUCT(COUNTIFS($I$5:$I$10,B$5:B$8,$J$5:$J$10,"PRESENT"))

B11 copied across
=SUMPRODUCT(COUNTIFS($I$5:$I$10,B$5:B$8,$J$5:$J$10,"ABSENT"))

M.
 
Upvote 0
Solution
Another option would be this, copied across and down.

22 03 27.xlsm
ABCDEFGHIJ
4Names3/01/20223/02/20223/03/20223/04/20223/05/2022Reference Table
5Person 1PCCPPPPRESENT
6Person 2EPPPPEPRESENT
7Person 3KMMPPKPRESENT
8Person 4CUUUCCPRESENT
9MABSENT
10Count Present42234UABSENT
11Count Absent02210
Grasor
Cell Formulas
RangeFormula
B10:F11B10=COUNT(FILTER(ROW(B$5:B$8),VLOOKUP(B$5:B$8,$I$5:$J$10,2,0)=MID($A10,7,7),""))
 
Upvote 0
Marcelo & Peter,

Thank you. Both solutions worked but I can only mark one as the answer.

I was thrown an additional request later, which was to also delineate by employee type. To which I was able to adapt Peter's use of the FILTER() function as follows:

Excel Formula:
=COUNT(FILTER(ROW(C$5:C$8),($B$5:$B$8="E")*(VLOOKUP(C$5:C$8,$J$5:$K$10,2,0)="PRESENT"),""))

Where "E" is the employee type.

Thank you again!

P.S. This situation has proven what I've known for several years: Once you get proficient in VBA it's easy to go straight to that and not use the built-in functions. Now I feel clueless with the built-ins!! Good thing this board exists!
 
Upvote 0
Glad you got a successful outcome. Thanks for letting us know. (y)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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