macro to subtract ID quantity from two sheets for same price

Amer Omar

New Member
Joined
Jan 27, 2024
Messages
24
Office Version
  1. 2019
Platform
  1. Windows
Hello ,
I would macro (nothing else) Merge QTY for ATTR for ID contains the same price and compare with the same ID for the same price in AMMR sheet then will subtract QTY in AMMR sheet from QTY in ATTR sheet for the same ID and same price.
the merging QTY will just be for ATTR . don't merge QTY for AMMR sheet .
so when subtract the QTY will search for duplicates ID in AMMR sheet until subtract the whole QTY based on ATTR sheet
after that will populate OK word for adjacent cell in BALANCE column in ATTR sheet and any ID contains OK word next time ignore from subtraction.

the same thing for AVSR,SSERT sheets should subtract QTY for duplicate ID in AVSR sheet from merging QTY in SSERT sheet.
after subtraction will be zero QTY for some ID in AMMR,AVSR sheets then shouldn't subtract from zero until doesn't show minus value , just ignore zero QTY for some ID when try again subtract when add new data in ATTR,SSERT
IMPORTANT NOTICE: when try subtract QTY and and doesn't cover whole QTY from the first ID then the remaining subtract form the next duplicate ID until finishing QTY based on ATTR or SSERT sheets.
ex: SDCMN 1000A for price=110 in AMMR sheet =15 ,10 QTY(rows2,13)
and ATTR sheet will be 16 so first subtract 15 from row2 and 1 from row 13 to become =9 and when subtract 2 in row6 from ATTR sheet to become final =7.
without for get change amounts in column BALANCE=QTY*PRICE


AMER.xlsm
ABCDEFG
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
208/01/2024AMMRSDCMN 1000AAASLN#15.00110.001,650.00
308/01/2024AMMRCVVBGT-100AASLN#20.00115.002,300.00
409/01/2024AMERCVVBGT-101AQQWNY#10.00111.001,110.00
509/01/2024AMERA111-300BAQQWNY#5.00100.00500.00
609/01/2024AMERA112-300BAQQWNY#22.00114.002,508.00
710/01/2024AMRAAVSDCMN 1000AAZZXX#10.00112.001,120.00
810/01/2024AMRAAVCVVBGT-100AZZXX#5.00113.00565.00
911/01/2024ASMANCVVBGT-100AFFXX#4.00117.00468.00
1012/01/2024ASMANA111-300BAASFXX#10.00112.001,120.00
1113/01/2024AMRAAVQWW-900O10AQWERR#5.00140.00700.00
1213/01/2024AMRAAVQWW-900O11AQWERR#20.00145.002,900.00
1313/01/2024AMRAAVSDCMN 1000AAQWERR#10.00110.001,100.00
AMMR



AMER.xlsm
ABCDEFG
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
208/01/2024RVVTTA111-300BSLLNO-002.00120.00240.00
309/01/2024RTSSSDCMN 1000ASLLNO-012.00144.00288.00
409/01/2024RTSSCVVBGT-100SLLNO-012.00143.00286.00
510/01/2024ARTTTSDCMN 1000ASLLNO-025.00140.00700.00
610/01/2024ARTTTCVVBGT-100SLLNO-025.00135.00675.00
710/01/2024ARTTTCVVBGT-101SLLNO-025.00137.00685.00
811/01/2024RTYYA111-300BSLLNO-033.00125.00375.00
911/01/2024RVVTTA111-300BSLLNO-004.00120.00480.00
AVSR


AMER.xlsm
ABCDEFG
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
213/01/2024AMMRSDCMN 1000ATTRR-0016.00110.001,760.00
314/01/2024AMMRCVVBGT-100TTRR-015.00115.00575.00
414/01/2024AMERCVVBGT-101TTRR-012.00111.00222.00
515/01/2024ASMANSDCMN 1000ATTRR-025.00112.00560.00
616/01/2024AMMRSDCMN 1000ATTRR-032.00110.00220.00
717/01/2024ASMANSDCMN 1000ATTRR-041.00112.00112.00
ATTR



AMER.xlsm
ABCDEFG
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
214/01/2024RVVTTA111-300BRSTTT-004.00120.00480.00
315/01/2024RTSSSDCMN 1000ARSTTT-012.00144.00288.00
416/01/2024RVVTTA111-300BRSTTT-021.00120.00120.00
517/01/2024RTSSCVVBGT-100RSTTT-032.00143.00286.00
618/01/2024ARTTTSDCMN 1000ARSTTT-042.00140.00280.00
719/01/2024ARTTTSDCMN 1000ARSTTT-052.00140.00280.00
SSERT




should be like this
AMER1.xlsm
ABCDEFG
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
208/01/2024AMMRSDCMN 1000AAASLN#0.00110.000.00
308/01/2024AMMRCVVBGT-100AASLN#15.00115.001,725.00
409/01/2024AMERCVVBGT-101AQQWNY#8.00111.00888.00
509/01/2024AMERA111-300BAQQWNY#5.00100.00500.00
609/01/2024AMERA112-300BAQQWNY#22.00114.002,508.00
710/01/2024AMRAAVSDCMN 1000AAZZXX#4.00112.00448.00
810/01/2024AMRAAVCVVBGT-100AZZXX#5.00113.00565.00
911/01/2024ASMANCVVBGT-100AFFXX#4.00117.00468.00
1012/01/2024ASMANA111-300BAASFXX#10.00112.001,120.00
1113/01/2024AMRAAVQWW-900O10AQWERR#5.00140.00700.00
1213/01/2024AMRAAVQWW-900O11AQWERR#20.00145.002,900.00
1313/01/2024AMRAAVSDCMN 1000AAQWERR#7.00110.00770.00
AMMR


AMER1.xlsm
ABCDEFG
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
208/01/2024RVVTTA111-300BSLLNO-000.00120.000.00
309/01/2024RTSSSDCMN 1000ASLLNO-010.00144.000.00
409/01/2024RTSSCVVBGT-100SLLNO-010.00143.00286.00
510/01/2024ARTTTSDCMN 1000ASLLNO-021.00140.00700.00
610/01/2024ARTTTCVVBGT-100SLLNO-025.00135.00675.00
710/01/2024ARTTTCVVBGT-101SLLNO-025.00137.00685.00
811/01/2024RTYYA111-300BSLLNO-033.00125.00375.00
911/01/2024RVVTTA111-300BSLLNO-002.00120.00240.00
10
11
12
13
AVSR




AMER1.xlsm
ABCDEFGH
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
213/01/2024AMMRSDCMN 1000ATTRR-0016.00110.001,760.00ok
314/01/2024AMMRCVVBGT-100TTRR-015.00115.00575.00ok
414/01/2024AMERCVVBGT-101TTRR-012.00111.00222.00ok
515/01/2024ASMANSDCMN 1000ATTRR-025.00112.00560.00ok
616/01/2024AMMRSDCMN 1000ATTRR-032.00110.00220.00ok
717/01/2024ASMANSDCMN 1000ATTRR-041.00112.00112.00ok
ATTR



AMER1.xlsm
ABCDEFGH
1DATECLIENTBRAND NOORDER NOQTYUNIT PRICEBALANCE
214/01/2024RVVTTA111-300BRSTTT-004.00120.00480.00ok
315/01/2024RTSSSDCMN 1000ARSTTT-012.00144.00288.00ok
416/01/2024RVVTTA111-300BRSTTT-021.00120.00120.00ok
517/01/2024RTSSCVVBGT-100RSTTT-032.00143.00286.00ok
618/01/2024ARTTTSDCMN 1000ARSTTT-042.00140.00280.00ok
719/01/2024ARTTTSDCMN 1000ARSTTT-052.00140.00280.00ok
SSERT


thanks in advanced
 

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