Offset Sum with Variable formula depending on row.

Scotster

Board Regular
Joined
May 29, 2017
Messages
59
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I've no idea how to describe what I'm looking for in a heading, so hopefully the below explains it a little better. Is there a more elegant way of calculating the below.

The formula I have in D6 is as follows:

Code:
=IF($C6="Net",SUM(OFFSET($D6,MATCH(1,($C1:$C6="Demand")*($B1:$B6=$B6)*($A1:$A6=$A6),0)-6,0):$D5),IF($C6="Demand",-10,5))

It's copied from D4 to D16, where D4 and D5 will REF error for the "Net" true calculation, but doesn't affect anything.

My aim is to replace the "-10" and "5" with a formula from another sheet. The reason for the convoluted method is there can be multiple Suppliers, so some parts cover 3 lines or more. The offset only allows for 6 lines at the maximum so I was hoping there would be a better option.

1679588489907.png


What I want is for the demand line to use one calculation, the net line to use another calculation and the remaining supply lines to use a 3rd calculation. There are 10000s of rows, so creating one formula to copy down the entire sheet I feel is beneficial, rather than using VBA to determine the individual formulae per row. The difficulty with the "Net" calculation, is that it's simply a sum of the rows above it..... up to and including the "Demand" row. With the "Demand" row varying in distance I've used the match to find the correct offset.

As always, any help gratefully appreciated :)
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Forgot to mention, Office version 2016 for this project.
 
Upvote 0
would you be kind enough to help the forum help you by using the xl2bb add in and posting a mini workbook of both the current worksheet and the sheet where the other data is held? If you cannot use xl2bb, then tables are much better than images. The forum would have to recreate your worksheet(s) manually which can have errors and is time consuming.

Also, just a typed example of expected outcomes would be most helpful.
 
Upvote 0
would you be kind enough to help the forum help you by using the xl2bb add in and posting a mini workbook of both the current worksheet and the sheet where the other day is held? If you cannot use xl2bb, then tables are much better than images. The forum would have to recreate your worksheet(s) manually which can have errors and is time consuming.

Also, just a typed example of expected outcomes would be most helpful.

Unfortunately I can't use the add in as I'm on a works PC. I've copied the resulting table below. Material is in "A3" for my formula example.

The reference formulas for the -10 and 5 are pretty extreme so I don't want to muddy the waters by including them.

MaterialLocationDemand/Sup/Net
Part 1Loc 1Demand-10
Part 1Loc 1Supp 15
Part 1Loc 1Net-5
Part 1Loc 2Demand-10
Part 1Loc 2Supp 15
Part 1Loc 2Supp 25
Part 1Loc 2Net0
Part 2Loc 1Demand-10
Part 2Loc 1Supp 15
Part 2Loc 1Net-5
Part 3Loc 1Demand-10
Part 3Loc 1Supp 15
Part 3Loc 1Net-5
 
Upvote 0
Unfortunately I can't use the add in as I'm on a works PC. I've copied the resulting table below. Material is in "A3" for my formula example.

The reference formulas for the -10 and 5 are pretty extreme so I don't want to muddy the waters by including them.

MaterialLocationDemand/Sup/Net
Part 1Loc 1Demand-10
Part 1Loc 1Supp 15
Part 1Loc 1Net-5
Part 1Loc 2Demand-10
Part 1Loc 2Supp 15
Part 1Loc 2Supp 25
Part 1Loc 2Net0
Part 2Loc 1Demand-10
Part 2Loc 1Supp 15
Part 2Loc 1Net-5
Part 3Loc 1Demand-10
Part 3Loc 1Supp 15
Part 3Loc 1Net-5

Okay, so as long as they have no bearing on the other part of the formula. I guess you are just using -10 and 5 as placeholders and will paste the other formula in later?
 
Upvote 0
Okay, so as long as they have no bearing on the other part of the formula. I guess you are just using -10 and 5 as placeholders and will paste the other formula in later?

Yes, exactly :)
 
Upvote 0
Bumping this up just to see if anyone can think of anything before I go with what I've got :)
 
Upvote 0
Bumping this up just to see if anyone can think of anything before I go with what I've got :)
Can you give in prose, the 3 calculations you want. It could be that a formula idea may be different from how you are envisioning it.
So, from what I gather...
If column C has DEMAND, you have a calculation ready to plug in, and you'll d that.
If column C has something other than NET or DEMAND, you have a calculation that is ready to plug in, and you'll do that

The question, that i'm thinking you want is for when Column C has NET... you want to sum all the amounts in column D from (and including) the first DEMAND above it through that row(that the NET is on)?

Is this correct?
 
Upvote 0
Can you give in prose, the 3 calculations you want. It could be that a formula idea may be different from how you are envisioning it.
So, from what I gather...
If column C has DEMAND, you have a calculation ready to plug in, and you'll d that.
If column C has something other than NET or DEMAND, you have a calculation that is ready to plug in, and you'll do that

The question, that i'm thinking you want is for when Column C has NET... you want to sum all the amounts in column D from (and including) the first DEMAND above it through that row(that the NET is on)?

Is this correct?

The reason I haven't included them is they are quite intrinsic and use multiple references/sheets/data sets etc. I don't think it would help find a solution.

What you have described is exactly what I am looking for. It doesn't need to include the Demand/etc elements of the formula. I just shared it to show what I was aiming to do. The main crux is pinpointing the offset from the demand dynamically.

Many thanks
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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