cell value disruption

aqeelnokia99

Board Regular
Joined
Dec 23, 2018
Messages
145
Office Version
  1. 2013
Platform
  1. Windows
POqtyavaible qty
a24
a3
b47
b3
b5
c33
c2
d112
d5
d6
d7

<tbody>
</tbody>

===========================
Result i want
POqtyavaible qtyResult
a242
a32
b474
b33
b5
c333
c2
d1121
d55
d66
d7

<tbody>
</tbody>

 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
This is for sure not the best way, but it works:

Drag E2 down...


Excel 2016 (Windows) 32 bit
ABCD
1POqtyavaible qtyResult
2a242
3a32
4b474
5b33
6b50
7c333
8c20
9d1121
10d55
11d66
12d70
Sheet4
Cell Formulas
RangeFormula
D2=IF(SUM(B2,D1)<=INDEX($C$2:$C$12,MATCH(A2,$A$2:$A$12,0)),B2,IF(INDEX($C$2:$C$12,MATCH(A2,$A$2:$A$12,0))-SUMPRODUCT(($A1:A$2=A2)*$D1:D$2)$C$2:$C$12,MATCH(A2,$A$2:$A$12,0))-SUMPRODUCT(($A1:A$2=A2)*$D1:D$2)))
 
Last edited:
Upvote 0
Here's a different approach that's a bit shorter:

D2: =IF(C2<>"",MIN(B2,C2),MIN(B2,LOOKUP(9E+307,C$2:C2)-SUM(INDEX(D$1:D1,LOOKUP(9E+307,C$1:C1,ROW(C$1:C1))):D1)))
 
Last edited:
Upvote 0
D2: =MIN(B2,SUMIF(A:A,A2,C:C)-SUMIF(A$1:A1,A2,D$1:D1))


this is too good can any one make video about this formula how its work
 
Upvote 0
Well, I don't know if it needs a video! :biggrin:

Here's how it works though. The first SUMIF sums up everything in column C matching the PO in column A. Since according to your layout, you only show the available quantity in one place for each PO, this will return the starting available quantity for the PO, no matter which row of the PO you're looking at.

The next SUMIF adds up all the used amounts for the PO above the current line. See how the ranges have an absolute reference indicator $ for the top row, but not the bottom row. So as you drag the formula down, the range grows. Since I started 1 row above the current row, the SUMIFS will sum everything we've used so far.

Then when you take the difference of the 2 SUMIFS, you have the remaining amount for the PO.

Finally, let's say column B has a quantity of 5, and you have a remaining amount of 7. If you take the minimum of 5 and 7, you get 5, which is what the result is. On the next row, the 5 would be added to the used amount, so the remaining amount would change to 2. Let's say on that row column B has a quantity of 6, and there's a remaining amount of 2. Again, we take the minimum of 6 and 2, get 2 and that's the result. On the next row, 2 would be added to the used amount, so the remaining amount would become 0. You kind of have to work through the cases before you can really see how it works, but it's actually pretty easy. You just need to look at things from a different angle, which is why it took 2 attempts for me to get to it.

I'm glad I could help.
 
Upvote 0

Forum statistics

Threads
1,214,667
Messages
6,120,814
Members
448,990
Latest member
rohitsomani

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