scheduling tool using SUMPRODUCT(SUMIF()) with arrays of different sizes

JayEhWhy

New Member
Joined
Mar 20, 2017
Messages
5

<colgroup><col><col span="3"><col><col><col></colgroup><tbody></tbody>
I am looking for some guidance on creating a scheduling tool.
What I have is a sheet of dates and job codes and a sheet with job codes and their duration.
I'd like to sum the duration of work in each month.

Sheet1 Sheet2
AB AB
1Code Date1CodeDuration
211/18/2018215
324/23/20183210
431/22/20184315
544/18/20175420
651/22/20186525
764/18/20177630
814/9/2018
922/16/2018
1034/25/2017

<colgroup><col><col span="3"><col><col><col></colgroup><tbody>
</tbody>

I have this working right now with the following code as long as the to arrays are the same size:
SUMPRODUCT(SUMIF('Sheet1'!A2:A7,'Sheet2'!A2:A7,'Sheet2'!B2:B7),(MONTH('Sheet1'!B2:B7)=4)*(YEAR('Sheet1'!B2:B7)=2017))

But as you can see Sheet1 is longer and will be changing in size.

Any ideas on making this work with different array sizes or an alternate approach?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
See if this does what you need

=SUMPRODUCT(SUMIF(Sheet2!$A$2:$A$7,Sheet1!A2:A10,Sheet2!$B$2:$B7),--(MONTH(Sheet1!B2:B10)=4),--(YEAR(Sheet1!B2:B10)=2017))

M.
 
Upvote 0
Would adding another column on sheet 1 be a possibility? For example in column C you could have duration and then do a lookup formula to bring in the duration of each code. Then on sheet 3 you could have a sumif formula to calculate this.
 
Upvote 0
Is the Sheet2 table exactly as shown (whereby the codes and durations have a linear relationship), or is that just a simplified example?

If it's the former try this formula

=SUMPRODUCT('Sheet1'!A2:A100,(TEXT('Sheet1'!B2:B100,"mmmm yyyy")="April 2017")+0)*5
 
Upvote 0
See if this does what you need

=SUMPRODUCT(SUMIF(Sheet2!$A$2:$A$7,Sheet1!A2:A10,Sheet2!$B$2:$B7),--(MONTH(Sheet1!B2:B10)=4),--(YEAR(Sheet1!B2:B10)=2017))

M.

Worked like a charm! Appreciate the help.
Can you explain why using the sheet2 Code first in the SUMIF made the difference?
 
Upvote 0
When Sheet1!A2:A10, a range with 9 rows, is used as the second argument of SUMIF it returns an array of equal size. In other words, SUMIF does the calculation (conditional sum) for each value in A2:A10 and returns an array of values - the result for each value present in A2:A10). In short, this array has the same size of the range A2:A10 and so SUMPRODUCT works properly.

On the other hand, when Sheet2!A2:A7, a range with 6 rows, is used as the second argument of SUMIF it returns an array with 6 values and SUMPRODUCT doesn't work correctly because the other arrays (Month and Year) have 9 values.

Hope i made myself clear

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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