Adding with Dynamic Ranges

Cat129

Board Regular
Joined
Oct 20, 2012
Messages
96
Hi All,

Hoping someone can help me figure this one out.

Ideally, I would like to do this with formulas so others who use the spreadsheet can understand how it works. If not possible then VBA will be good.

I will try to explain the best I can. We have multiple assemblies with sub assemblies, some have up to 9 sub assemblies. Each given a level number, so all the assembly 3's below a 2 make up assembly 2, and all the 4 assemblies below assembly 3 make up that one, so on and so on.

I cant just add up all the 3's because they will be different depending on the parent assembly 2, and this is true for every level

What I need to do is all all the totals of the very bottom level assembly, put that total into its parent assembly, and continue this until we get to one. The reason we have to do it this was is because the very bottom level assembly parts will have the correct weight on them, but the parent assembly may have an estimated weight that is incorrect. We have to assume that the children are always correct.

Below I have just chucked some random numbers in and manually put in what the weight should be showing in the Calculated Weight Column.

I really hope I have made sense and someone can help me.

Thanks.

AssemblyTotal MassCalculated Weight
21.0062 ( 30 + 32)
32.0030 (From 4 below)
43.0030 (4 + 5 + 6 + 7 + 8 + 9)
54.00
55.00
56.00
57.00
58.00
39.0032 (10 + 11 + 12)
410.00
411.00
412.00

<tbody>
</tbody>
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
4 3.00 30 (4 + 5 + 6 + 7 + 8 + 9)
Why is 9 included in this?

9 is part of assembly 3 which is not below assembly 4.
 
Upvote 0
Sorry, You are right. It is a Typo. I've just tried to correct it. But I cant. Appologies
 
Last edited:
Upvote 0
Hi

I'm looking at your table and I don't understand how you account for the Total Mass numbers 1, 2, 3 and 9.

I don't see them anywhere in your calculations.

Shouldn't for ex. the calculated value of the last Total Mass 3 (in row 10) be equal to (9+10+11+12) including the value 9?
In which calculated value are you including the value 9?
 
Upvote 0
I think the OP is s saying the 9.00 in line 10 is an estimated value and shouldnt be part of the calculation
As with line 4 which doesnt include the 3.00 that is, hence the correct method of calculating backwards from the highest sub part number.
 
Upvote 0
I think the OP is s saying the 9.00 in line 10 is an estimated value and shouldnt be part of the calculation
As with line 4 which doesn't include the 3.00 that is, hence the correct method of calculating backwards from the highest sub part number.

Yes, This is exactly right. Sorry if it wasn't very clear.
 
Upvote 0
Try in C2:

=IF((A2=A1)+(A2=A3),"",SUMPRODUCT(1-(A2:A100<A3:A101),B2:B100,--(ROW(A2:A100)<ROW(A2)+MATCH(TRUE,INDEX((A3:A101=A2)+(A3:A101="")>0,),0))))

Copy down
 
Last edited:
Upvote 0
Try in C2:

=IF((A2=A1)+(A2=A3),"",SUMPRODUCT(1-(A2:A100<A3:A101),B2:B100,--(ROW(A2:A100)<ROW(A2)+MATCH(TRUE,INDEX((A3:A101=A2)+(A3:A101="")>0,),0))))

Copy down


You must be some kind of wizard. This is incredible, and it works. Any chance you can explain it to me so I understand it better. I spent 3 days staring at this trying various things and failed.

You are amazing. Thank You
 
Upvote 0
Hi, I'm glad it helps.

The first part

IF((A2=A1)+(A2=A3),"",

is easy, you are only interested in a result in case the Assembly value is different from either the previous or the following value.

The SumProduct() calculates the results you are interested in.

You only want to add

- the values in column B, 'B2:B100'

with the 2 conditions

1 - the value in column A, Assembly, is bigger than or equal to the next one '1-(A2:A100<A3:A101)' that you could also write '0+(A2:A100>=A3:A101)'

2 - you are only interested in the values until you reach an Assembly value that is equal to the current one or that is blank (meaning end of the table)
'--(ROW(A2:A100)<ROW(A2)+MATCH(TRUE,INDEX((A3:A101=A2)+(A3:A101="")>0,),0)))'

Hope this helps.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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