decreasing from a stable Quantity Macro

shahsavand

Board Regular
Joined
Dec 8, 2014
Messages
74
i wanna decrease my stock with the last time i used my inventory.
for example ID no 1. my need is 200 and my stock is 5000 so my shortage is 5000-200=4800 then you can see we have this Id in another row in which my requirement is 54.here i wanna calculate it like this 4800-54=4746
(stock quantity is stable for each ID)
i need a macro for doing it.please somebody help me.

ProductIDNEEDSTOCKShortage
A12005000
4800
A22002000
A32512-13
A453631
A56254248
B642319
B7213615
B15450004946
B26200194
c656910031
c35412-42
c1426588-177
c26329967

<tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi,

Perhaps you can try a formula approach. Something like this in cell E2 and copy down:

Code:
=IF(
    ISNUMBER(MATCH(B2, B$1:B1, 0)),
    VLOOKUP(B2, B$1:E1, 4, 0),
    D2)
 - C2


Excel 2013
ABCDE
1ProductIDNEEDSTOCKShortage
2A120050004800
3A22002000
4A32512-13
5A453631
6A56254248
7B642319
8B7213615
9B15450004746
10B26200-6
11C656910031
12C35412-67
13C1426588-177
14C26329967
Sheet1
 
Upvote 0
Hi,

Perhaps you can try a formula approach. Something like this in cell E2 and copy down:

Code:
=IF(
    ISNUMBER(MATCH(B2, B$1:B1, 0)),
    VLOOKUP(B2, B$1:E1, 4, 0),
    D2)
 - C2


Excel 2013
ABCDE
1ProductIDNEEDSTOCKShortage
2A120050004800
3A22002000
4A32512-13
5A453631
6A56254248
7B642319
8B7213615
9B15450004746
10B26200-6
11C656910031
12C35412-67
13C1426588-177
14C26329967
Sheet1


Please help me
 
Upvote 0
Oops, sorry, perhaps try this version instead:

Code:
=IF(
    ISNUMBER(MATCH(B2, B$1:B1, 0)),
    LOOKUP(2, 1 / (B$1:B1 = B2), E$1:E1),
    D2)
 - C2



it's not working.the result is as per below table.
for example Id no 1: 5000-200=4800 which is correct.
4800-54=4746 is also correct.but third one must be like 4746-69=4677 but instead it will count like this: 4746-(69-54)=4731



ProductIDNEEDSTOCKShortage
A1
20050004800
A22002000
A32512-13
A453631
A56254248
B642319
B7213615
B1
54
50004746
B26200-6
c1
69
1004731
c1
54124746
c126550004535
c13250004768

<colgroup><col span="4"><col></colgroup><tbody>
</tbody>

please help me.thank you dear
 
Upvote 0
Are you sure you are implementing it exactly as described? Here are my results:


Excel 2013
ABCDE
1ProductIDNEEDSTOCKShortage
2A120050004800
3A22002000
4A32512-13
5A453631
6A56254248
7B642319
8B7213615
9B15450004746
10B26200-6
11c1691004677
12c154124623
13c126550004358
14c13250004326
Sheet1
Cell Formulas
RangeFormula
E2=IF(ISNUMBER(MATCH(B2, B$1:B1, 0)), LOOKUP(2, 1 / (B$1:B1 = B2), E$1:E1), D2) - C2
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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