cell value disruption

aqeelnokia99

Board Regular
Joined
Dec 23, 2018
Messages
145
Office Version
  1. 2013
Platform
  1. Windows
[TABLE="width: 332"]
<tbody>[TR]
[TD="align: center"]PO[/TD]
[TD="align: center"]qty[/TD]
[TD="align: center"]avaible qty[/TD]
[/TR]
[TR]
[TD="align: center"]a[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]a[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]b[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]7[/TD]
[/TR]
[TR]
[TD="align: center"]b[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]b[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]c[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD="align: center"]c[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]12[/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]7[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

===========================
Result i want
[TABLE="width: 275"]
<tbody>[TR]
[TD="align: center"]PO[/TD]
[TD="align: center"]qty[/TD]
[TD="align: center"]avaible qty[/TD]
[TD="align: center"]Result[/TD]
[/TR]
[TR]
[TD="align: center"]a[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD="align: center"]a[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD="align: center"]b[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD="align: center"]b[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"][/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD="align: center"]b[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]c[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD="align: center"]c[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]12[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"][/TD]
[TD="align: center"]5[/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]6[/TD]
[TD="align: center"][/TD]
[TD="align: center"]6[/TD]
[/TR]
[TR]
[TD="align: center"]d[/TD]
[TD="align: center"]7[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]

 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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! :grin:

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,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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