Roster sum function question

valtam

New Member
Joined
Jan 15, 2009
Messages
7
Hello,

I am stumped on a roster I have been working on. There are several types of shifts for the workers, A, DD, S12 and so on. Each of those shifts has a numeric value, eg. DD = a 10 hour shift. So I'm guessing I need a table as a lookup reference like so?

Shift CodeHours
A8
DD10
S1212

<tbody>
</tbody>


When I type in the Shift Codes in B2, B3 and B5 for example, I'd like B9 to show the total hours worked for Bob as a number. I'm having a hard time working out the formula that works best for this situation. Any guidance would be greatly appreciated. Thank you.


ABCDE
1DayBobMaxEdyGav
2MonAES12D
3TueDDDDAE
4Wed
5ThursS12
6Fri
7Sat
8Sun
930
15
20
10

<tbody>
</tbody>
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
If you dont get a better answer (and Im positive you will, just cant think right now), give this brute-force option a try...
=SUM(IFERROR(VLOOKUP(B2,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B3,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B4,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B5,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B6,$J$2:$K$4,2,0),0))

I put your shiftcode/hours in J1:K4
 
Upvote 0
Thanks for your help Ford, I used your formula and get the following error:

9VOCbca.png
 
Upvote 0
Hey,

I tried to use FDibbins his code. And I noticed if you copy the code from his post there is a space (after the 2nd line; before the 3rd) where there shouldn't be one. I think that will solve your problem.

And I might have an other solution to your problem. Why don't you try:

=SUMPRODUCT((B2=$I$2:$I$6)*$J$2:$J$6)+SUMPRODUCT((B3=$I$2:$I$6)*$J$2:$J$6)+SUMPRODUCT((B4=$I$2:$I$6)*$J$2:$J$6)+SUMPRODUCT((B5=$I$2:$I$6)*$J$2:$J$6)+SUMPRODUCT((B6=$I$2:$I$6)*$J$2:$J$6)+SUMPRODUCT((B7=$I$2:$I$6)*$J$2:$J$6)+SUMPRODUCT((B8=$I$2:$I$6)*$J$2:$J$6)

Your Shiftcode/Hours are in I2:J6

Regards Barbra

PS: this was my first post and I hope this was helpfull.
 
Upvote 0
Thank you Barbra, your solution worked - a great first post for you :) For the record, I did try the formula from Ford but without success, even with the correct copy format. Thank you to Ford as well for helping :)
 
Upvote 0
You can simplify Barbra's formula further to =SUMPRODUCT(((B2=$I$2:$I$6)+(B3=$I$2:$I$6)+(B4=$I$2:$I$6)+(B5=$I$2:$I$6)+(B6=$I$2:$I$6)+(B7=$I$2:$I$6)+(B8=$I $2:$I$6))*$J$2:$J$6)

I'm sure it can go neater than this though as well.
 
Last edited:
Upvote 0
Interesting that you say it did not work for you? (That extra space in IFERROR must have been a copy/paste error). I tried mu formula again and it works ok...

A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
K​
1​
Day
Bob
Max
Edy
Gav
Shift Code
Hours
2​
Mon
A
E
S12
D
A
8
3​
Tue
DD
DD
A
E
DD
10
4​
Wed
S12
12
5​
Thurs
S12
6​
Fri
7​
Sat
8​
Sun
9​
Mine
30
10
20
0
10​
11​
Yours
30
15
20
10

B9=SUM(IFERROR(VLOOKUP(B2,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B3,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B4,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B5,$J$2:$K$4,2,0),0),IFERROR(VLOOKUP(B6,$J$2:$K$4,2,0),0)) copied across

There is no matching code in column E, hence my total of 0
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,306
Members
449,218
Latest member
Excel Master

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