macro to populate averages prices for two sheets and create report

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
Hello
I search for macro to deal with at least 3000 items and cloud be 9000 rows for each sheet .
in two sheets I have data for items in columns D:F and the price in column H . so what I want when merge duplicates items based on matching columns D: E and when repeat the same item with different price should use price averages but when merge items should be separated for each sheet alone , also when merge quantity should just be for SVR sheet (means ignoring QTY totally in SR sheet when merge as I did REPORT sheet .
when merge data should be based on two cells (dates) should merge within two dates in E2,G2 . if the E2,G2 are empty then should be empty from row 5 .every time run the macro should clear data from row5 before brings the data , not repeat to the bottom the same data have already copied.
in REPORT sheet SVR header is averages prices from column H for SVR sheet ,SR header is averages prices from column H for SR sheet and in last row(TOTAL) should sum the columns I,J,K and in column L will subtract and sum for I:K as I put the formulas .
if they data are existed in SVR but not in SR should show in REPORT sheet , but if they data are existed in SR ,not in SVR should NOT show in REPORT sheet .
finally when copy data to report sheet I want keep the formatting (numbers,borders....) .

SVR sheet
TR.xlsx
ABCDEFGHI
1ITEMDATEINV.NOBRANDTYPEORIGINQTY PRICETOTAL
2115/06/2023BSTR_23448BS 750R16R230JAP4.00500.002,000.00
3215/06/2023BSTR_23448BS 700R16R230JAP2.00400.00800.00
4SUM15/06/2023BSTR_234482,800.00
5115/09/2023BSTR_23449GO 1200R20AZ0026CHI1.00920.00920.00
6215/09/2023BSTR_23449GO 1200R20AZ0083CHI2.001,000.002,000.00
7SUM15/09/2023BSTR_234492,920.00
8115/09/2023BSTR_23450BS 1200R20G580JAP1.001,800.001,800.00
9215/09/2023BSTR_23450BS 1200R20G580THI1.001,800.001,800.00
10315/09/2023BSTR_23450BS 1200R20R187THI1.001,800.001,800.00
11SUM15/09/2023BSTR_234505,400.00
12120/09/2023BSTR_23451BS 750R16R230JAP4.00450.001,800.00
13220/09/2023BSTR_23451BS 1200R20R187THI2.001,650.003,300.00
14SUM20/09/2023BSTR_234515,100.00
15121/09/2023BSTR_23452BS 750R16R230JAP2.00480.00960.00
16221/09/2023BSTR_23452BS 1200R20R187THI3.001,550.004,650.00
17SUM21/09/2023BSTR_23452BS 1200R20G580THI4.001,900.007,600.00
18121/09/2023BSTR_23453BS 1400R20VSJJAP2.002,800.005,600.00
19SUM21/09/2023BSTR_234535,600.00
20121/09/2023BSTR_23454BS 1400R20VSJJAP2.003,000.006,000.00
21SUM21/09/2023BSTR_234546,000.00
SVR



SR sheet
TR.xlsx
ABCDEFGHI
1ITEMDATEINV.NOBRANDTYPEORIGINQTY PRICETOTAL
2110/06/2023BSJ_23444BS 215/60R16ER30JAP4.00430.001,720.00
3SUM10/06/2023BSJ_234441,720.00
4115/06/2023BSJ_23445GO 1200R20AZ0026CHI2.00955.001,910.00
5SUM15/06/2023BSJ_234451,910.00
6115/09/2023BSJ_23446GO 1200R20AZ0026CHI2.00950.001,900.00
7SUM15/09/2023BSJ_234461,900.00
8115/09/2023BSJ_23447BS 1200R20G580JAP1.002,000.002,000.00
9215/09/2023BSJ_23447BS 1200R20G580THI1.002,000.002,000.00
10315/09/2023BSJ_23447BS 1200R20R187THI1.001,650.001,650.00
11SUM15/09/2023BSJ_234475,650.00
12116/09/2023BSJ_23448GO 1200R20AZ0026CHI1.001,000.001,000.00
13SUM16/09/2023BSJ_234481,000.00
14117/09/2023BSJ_23449BS 1200R20G580JAP2.00950.001,900.00
15217/09/2023BSJ_23449BS 1200R20G580THI2.00990.001,980.00
16SUM17/09/2023BSJ_234493,880.00
17117/09/2023BSJ_23450BS 1200R24G580JAP2.002,200.004,400.00
18SUM17/09/2023BSJ_234504,400.00
19117/09/2023BSJ_23450BS 1200R24G580JAP1.001,950.001,950.00
20SUM17/09/2023BSJ_234501,950.00
SR


REPORT sheet


TR.xlsx
EFGHIJKL
1FROM DATETO DATE
2
3
4ITEMBRANDTYPEORIGINQTYSVRSRNET
5
6
7
8
9
10
11
12
13
REPORT


result in REPORT sheet after write dates in E2,G2

TR.xlsx
EFGHIJKL
1FROM DATETO DATE
215/06/202321/09/2023
3
4ITEMBRANDTYPEORIGINQTYSVRSRNET
51BS 700R16R230JAP2.00400.000.00800.00
62BS 750R16R230JAP8.00475.000.003,800.00
73GO 1200R20AZ0026CHI1.00920.00969.00-49.00
84GO 1200R20AZ0083CHI2.001,000.000.002,000.00
95BS 1200R20G580JAP1.001,800.001,475.00325.00
106BS 1200R20G580THI5.001,850.001,495.007,755.00
117BS 1200R20R187THI6.001,667.001,650.008,352.00
128BS 1400R20VSJJAP4.002,900.000.0011,600.00
13TOTAL29.0011,012.005,589.00313,759.00
REPORT
Cell Formulas
RangeFormula
L5:L13L5=I5*J5-K5
I13:K13I13=SUM(I5:I12)
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,215,069
Messages
6,122,952
Members
449,095
Latest member
nmaske

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