Weeks of Supply Calculation with Quarter Breaks

patrick99

New Member
Joined
Aug 24, 2020
Messages
1
Office Version
  1. 2013
Platform
  1. Windows
Hello

I am trying to modify the formula in this THREAD to account for a quarter total. My data spans a year in weekly buckets with a quarter total every 13 weeks.

Original formula:
VBA Code:
=(SUMPRODUCT(--(SUM(B4)>=SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))))+ABS(LOOKUP(0,(SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))-SUM(B4)-C3:$AB3)/C3:$AB3)))

Updated formula:
VBA Code:
=IF(13-B2>=SUMPRODUCT(--(SUM(B4)>=SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))))+IF(ABS(LOOKUP(0,(SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))-SUM(B4)-C3:$AB3)/C3:$AB3))=1,0,ABS(LOOKUP(0,(SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))-SUM(B4)-C3:$AB3)/C3:$AB3))),SUMPRODUCT(--(SUM(B4)>=SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))))+IF(ABS(LOOKUP(0,(SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))-SUM(B4)-C3:$AB3)/C3:$AB3))=1,0,ABS(LOOKUP(0,(SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))-SUM(B4)-C3:$AB3)/C3:$AB3))),SUMPRODUCT(--(SUM(B4)>=SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))))+IF(ABS(LOOKUP(0,(SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))-SUM(B4)-C3:$AB3)/C3:$AB3))=1,0,ABS(LOOKUP(0,(SUBTOTAL(9,OFFSET(C3:$AB3,,,,COLUMN(C3:$AB3)-COLUMN(C3)+1))-SUM(B4)-C3:$AB3)/C3:$AB3)))-1)

The original formula overstated the integer part by 1 in some cases.
The updated formula the first part (integer) of the formula calculates correctly, I think due to my quarter total being a "SUBTOTAL" which is ignored. The second half (fractional) is incorrect.
Is there an easier way to do this? This formula will need to be inserted with VBA and is awfully long.
I could probably live with the incorrect fractional part since it doesn't always happen and my example values are unlikely.
 

Attachments

  • fwdweeks.jpg
    fwdweeks.jpg
    111.6 KB · Views: 6

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,215,011
Messages
6,122,677
Members
449,092
Latest member
tayo4dgacorbanget

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