• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Summing a variable range

JDC8457

Member
I attached a sample sheet with data.

The user inputs the desired start day in cell C2. In this example, day 5.
The user inputs the desired lead time in cell C4. In this example, 6.

The lead time entered in C4 determines how many cells are added to arrive at the rolling forecast (column C). In the example, the answer is 450 unit because the rolling forecast adds the six values in column B starting at day 5. I did a simple =sum and copied it down. But this is not what the user wants.

The user wants to be able to make changes to the lead time and have the rolling forecast automatically update.

I need help with a formula where the user can input any lead time change in C4, and that change is reflected in the rolling forecast totals. So, if the lead time were changed to 4, the rolling forecast total beginning at day 5 should be 260 units.

Many thanks.
 

Attachments

  • Sample for Ninjas.xlsx
    10 KB · Views: 11
I only use Excel 365 so these formula may not help!
Code:
= LET(
    day, SEQUENCE(leadTime, , startDay),
    SUM(INDEX(Units, day))
  )
or
Code:
= LET(
    selectedUnits, TAKE(DROP(Units,startDay-1),leadTime),
    SUM(selectedUnits)
  )
Failing that, you could try the formula
Code:
= 10 * leadTime * (2*startDay + leadTime -1) / 2
and dispense with the table.
 
As long as the first day begins in Row 8, this works
=SUM(INDIRECT("B"&7+startDay&":B"&5+leadTime+startDay+1))

To make dynamic, create another named range and call it day1Begins. For your spreadsheet, the value is 8. The formula changes to
=SUM(INDIRECT("B"&day1Begins-1+startDay&":B"&day1Begins-2+leadTime+startDay))

Use a formula for Rolling: =SUM(INDIRECT("B"&ROW(B8)&":B"&ROW(B8)+leadTime-1))
 
Last edited:
Back
Top