Extraction same sheet name from files in folder and merge the same price

abdo meghari

Well-known Member
Joined
Aug 3, 2021
Messages
664
Office Version
  1. 2019
Hello,
I would macro, not POWER QUERY to extract the whole sheets from files are existed in directory D:\ab\INVOICES
so every file contains one sheet , the same sheet name .
INV1.xlsm
BCDEF
21ITEMBRANDQTYPRICEBALANCE
221VEGA 70A R KOR4.00500.002,000.00
232VEGA 55A R KOR2.00425.00850.00
243LARGEST 60A L HIGH JAP2.00440.00880.00
254KM 215/65R16 TA31 KOR4.00460.001,840.00
265265/70R16 ALGERIA4.00630.002,520.00
276KM 205/65R16 HS63 KOR4.00445.001,780.00
287GC 385/65R22.5 AT131 CHI2.001,650.003,300.00
298KM 265/70R16 KOR4.00880.003,520.00
309DONGA 66A L KOR2.00460.00920.00
3110KM 235/65R17 HP71 KOR4.00625.002,500.00
3211KM 235/55R19 PS71 KOR4.00675.002,700.00
3312DROUB 90A L KOR1.00575.00575.00
3413KM 13R22.5 MA11 KOR2.002,550.005,100.00
35TOTAL39.0028,485.00
SH1
Cell Formulas
RangeFormula
D35,F35D35=SUM(D22:D34)
F22:F34F22=E22*D22



INV2.xlsm
BCDEF
21ITEMBRANDQTYPRICEBALANCE
221VEGA 70A R KOR1.00500.00500.00
232VEGA 55A R KOR2.00425.00850.00
243LARGEST 60A L HIGH JAP2.00440.00880.00
254KM 215/65R16 TA31 KOR1.00460.00460.00
265265/70R16 ALGERIA4.00630.002,520.00
276KM 205/65R16 HS63 KOR4.00450.001,800.00
287GC 385/65R22.5 AT131 CHI12.001,640.0019,680.00
298KM 265/70R16 KOR4.00880.003,520.00
309KM 235/65R17 HP71 KOR1.00875.00875.00
3110KM 235/55R19 PS71 KOR2.00670.001,340.00
32TOTAL33.0032,425.00
SH1
Cell Formulas
RangeFormula
D32,F32D32=SUM(D22:D31)
F22:F31F22=E22*D22



INV3.xlsm
BCDEF
21ITEMBRANDQTYPRICEBALANCE
221BJS 13R22.5 MA11 KOR10.002,555.0025,550.00
232KM 13R22.5 MA11 KOR12.002,000.0024,000.00
24TOTAL22.0049,550.00
SH1
Cell Formulas
RangeFormula
D24,F24D24=SUM(D22:D23)
F22:F23F22=D22*E22



so the result in OUTPUT file into result sheet will already be existed and rename sheet for each file contains same sheet name based on file name INV1,INV2,INV3 before RESULT sheet. after data copy the data from sheets and merge QTY in column D for each brand IN COLUMN C if the price is the same thing in column E for duplicates brands whether in the same sheet or all of sheets across files otherwise don't merge , surely without forget insert TOTAL row to sum amounts.


before
OUTPUT.xlsm
BCDEF
21ITEMBRANDQTYPRICEBALANCE
22
23
24
25
26
27
28
RESULT




after
OUTPUT.xlsm
BCDEF
21ITEMBRANDQTYPRICEBALANCE
221VEGA 70A R KOR5500.002,500.00
232VEGA 55A R KOR4425.001,700.00
243LARGEST 60A L HIGH JAP4440.001,760.00
254KM 215/65R16 TA31 KOR5460.002,300.00
265265/70R16 ALGERIA8630.005,040.00
276KM 205/65R16 HS63 KOR4445.001,780.00
287GC 385/65R22.5 AT131 CHI21,650.003,300.00
298KM 265/70R16 KOR8880.007,040.00
309DONGA 66A L KOR2460.00920.00
3110KM 235/65R17 HP71 KOR4625.002,500.00
3211KM 235/55R19 PS71 KOR4675.002,700.00
3312DROUB 90A L KOR1575.00575.00
3413KM 13R22.5 MA11 KOR22,550.005,100.00
3514KM 205/65R16 HS63 KOR4450.001,800.00
3615GC 385/65R22.5 AT131 CHI121,640.0019,680.00
3716KM 235/65R17 HP71 KOR1875.00875.00
3817KM 235/55R19 PS71 KOR2670.001,340.00
3918BJS 13R22.5 MA11 KOR102,555.0025,550.00
4019KM 13R22.5 MA11 KOR122,000.0024,000.00
41TOTAL94110,460.00
RESULT
Cell Formulas
RangeFormula
D41,F41D41=SUM(D22:D40)

every time when run macro should delete sheets before RESULT sheet also delete data in RESULT sheet before brings data.
thanks
 
this is what I have.
q.JPG

by the way works with 2019 version , but 2010 not !
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I happen to have Excel 2010 and when I tested the macro using 2010, it worked properly for me. this is the result:
OUTPUT2.xlsm
BCDEF
21ITEMBRANDQTYPRICEBALANCE
221VEGA 70A R KOR6500.003,000.00
232VEGA 55A R KOR4425.001,700.00
243LARGEST 60A L HIGH JAP4440.001,760.00
254KM 215/65R16 TA31 KOR7460.003,220.00
265265/70R16 ALGERIA8630.005,040.00
276KM 205/65R16 HS63 KOR4445.001,780.00
287GC 385/65R22.5 AT131 CHI21,650.003,300.00
298KM 265/70R16 KOR8880.007,040.00
309DONGA 66A L KOR2460.00920.00
3110KM 235/65R17 HP71 KOR4625.002,500.00
3211KM 235/55R19 PS71 KOR4675.002,700.00
3312DROUB 90A L KOR1575.00575.00
3413KM 13R22.5 MA11 KOR22,550.005,100.00
3514KM 215/65R16 TA31 KOR2450.00900.00
3615KM 205/65R16 HS63 KOR4450.001,800.00
3716GC 385/65R22.5 AT131 CHI121,640.0019,680.00
3817KM 235/65R17 HP71 KOR1875.00875.00
3918KM 235/55R19 PS71 KOR2670.001,340.00
4019BJS 13R22.5 MA11 KOR102,555.0025,550.00
4120KM 13R22.5 MA11 KOR362,000.0072,000.00
4221BJS 14R22.5 MA11 KOR102,500.0025,000.00
4322KM 14R22.5 MA11 KOR122,500.0030,000.00
44TOTAL145215,780.00
RESULT
Cell Formulas
RangeFormula
D44,F44D44=SUM(D22:D43)
F22:F43F22=D22*E22

I don't know why your version of 2010 is not working.
 
Upvote 0

Forum statistics

Threads
1,225,504
Messages
6,185,360
Members
453,288
Latest member
rlmorales2000

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