match & copy and sum values into last threes columns across multiple sheets

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
I have many sheets . the result should show the values in sheet report into last three columns which contains headers (ARRIVED , SALES ) .so should match columns B,C,D in sheet REPORT with the others sheets . let's take column ARRIVED after matching column B,C,D should sum the values in column E in sheet (PURCHASE,RETURNS) and column F in sheet(SALES). for instance 175/70R14 MY02 THI (200+10+100)=310.
as to column SALES after matching column B,C,D .should sum the values in column E in sheet (SAL1,SALES) .for instance
825R16 R180 JAP (50+200)=250.
NOTE: every month I issue three columns . so should search the two last columns (arived,sales) and fill the values under theses columns .
also I highlighted the values which match and addion or summing and it will increase data in sheet report about 1500 rows


report (11) .xlsm
BCDEFGHIJKLM
1JULYAUGUSTSEPTEMBER
2SizePatternOrigin Arrived SalesStock Arrived SalesStock Arrived SalesStock
3175/70R13B25INDO---
4175/70R13EP150THI8444--
5185/70R13EP150INDO884844
6175/65R14EP150INDO---
7175/70R14EP150THI4444
8175/70R14MY02THI---
9185/65R14TECTHI99811
10185/65R14EP150INDO1613358--
11 185/65R14150EZINDO--
12185/65R15TC10INDO---
13185/65R15T005INDO---
14185/65R15T01JAP---
15185/65R15B250JAP---
16195/60R15AR20INDO---
17195/60R15EP150THI44-4--
18195/60R15T001JAP---
19 195/60R15150EZTHI-
20255/70R16H005THI---
21265/70R16D850THI---
22265/70R16D840THI---
23275/70R16H005THI---
24275/70R16D694JAP444--
25LT285/75R16AT001JAP---
26TTL49212813329--9
27285/60R18D850JAP---
28245/40R20RE050JAP---
29265/50R20SPORTJAP---
30275/30R20RE050JAP---
31275/40R20DHPJAP-89
32275/55R20D680JAP---
33285/30R20RE0050AJAP---
34315/35R20SPORTJAP---
35TTL-----8--9
36750R16VSJTHI201010556565
37825R16R180THI-111
38TTL20101056-66--66
REPORT
Cell Formulas
RangeFormula
M36:M37,M32:M34,J36:J37,J32:J34,M27:M30,M20:M25,J27:J30,J20:J25,M3:M18,J12:J18,J3:J10J3=G3+H3-I3
E26:M26E26=SUM(E3:E25)
E35:M35E35=SUM(E27:E34)
G36:G37,G27:G34,G3:G25G3=E3-F3
E38:M38E38=SUM(E36:E37)






report (11) .xlsm
ABCDE
1ITEMBRANDTYPEORIGINQTY
21 175/70R14EP150THI200.00
32 175/70R14MY02THI250.00
43 185/65R14EP150IND300.00
54 185/65R14TECTHI400.00
65 185/65R15T005IND500.00
76 195/60 R15EP150THI500.00
87 750R16VSJTHI1000.00
98 825R16R180THI1200.00
PURCHASE



report (11) .xlsm
ABCDE
1ITEMBRANDTYPEORIGINQTY
21 175/70R14EP150THI10.00
32 175/70R14MY02THI20.00
43 185/65R14TECTHI15.00
54 185/65R15T005IND4.00
65 750R16VSJTHI20.00
76 825R16R180THI15.00
RETURNS



report (11) .xlsm
ABCDE
1ITEMBRANDTYPEORIGINQTY
21 750R16VSJTHI50.00
32 825R16R180THI50.00
SAL1



report (11) .xlsm
ABCDEF
1ITEMBRANDTYPEORIGINSALESRETURNS
21 175/70R14EP150THI150.00100.00
32 175/70R14MY02THI10.00
43 185/65R14EP150IND15.00
54 185/65R14TECTHI20.00
65 185/65R15T005IND100.0050.00
76 750R16VSJTHI10.00
87 825R16R180THI200.0010.00
SALES



should be result in sheet REPORT
report (11) .xlsm
BCDEFGHIJKLM
1JULYAUGUSTSEPTEMBER
2SizePatternOrigin Arrived SalesStock Arrived SalesStock Arrived SalesStock
3175/70R13B25INDO---
4175/70R13EP150THI8444--
5185/70R13EP150INDO884844
6175/65R14EP150INDO---
7175/70R14EP150THI444310.00150164
8175/70R14MY02THI--280.00280
9185/65R14TECTHI9981415.0020396
10185/65R14EP150INDO1613358-300.0015285
11 185/65R14150EZINDO--
12185/65R15TC10INDO---
13185/65R15T005INDO--554.00100454
14185/65R15T01JAP---
15185/65R15B250JAP---
16195/60R15AR20INDO---
17195/60R15EP150THI44-4-500.00500
18195/60R15T001JAP---
19 195/60R15150EZTHI-
20255/70R16H005THI---
21265/70R16D850THI---
22265/70R16D840THI---
23275/70R16H005THI---
24275/70R16D694JAP444--
25LT285/75R16AT001JAP---
26TTL492128133292,3592852,083
27285/60R18D850JAP---
28245/40R20RE050JAP---
29265/50R20SPORTJAP---
30275/30R20RE050JAP---
31275/40R20DHPJAP-89
32275/55R20D680JAP---
33285/30R20RE0050AJAP---
34315/35R20SPORTJAP---
35TTL-----8--9
36750R16VSJTHI20101055651,030501,045
37825R16R180THI-111,225250976
38TTL20101056-662,2553002,021
REPORT
Cell Formulas
RangeFormula
M36:M37,M32:M34,J36:J37,J32:J34,M27:M30,M20:M25,J27:J30,J20:J25,M3:M18,J12:J18,J3:J10J3=G3+H3-I3
E26:M26E26=SUM(E3:E25)
E35:M35E35=SUM(E27:E34)
G36:G37,G27:G34,G3:G25G3=E3-F3
E38:M38E38=SUM(E36:E37)

*** is short of JAPAN
thanks in advance
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I have had a go at solving your problem but it is not complete and doesn't give the correct asnwer but it might get you started. I have run out of time.
VBA Code:
Sub testr()
   Dim Dic As Object
   Set Dic = CreateObject("Scripting.dictionary")
    Dic.CompareMode = vbTextCompare

With Worksheets("PURCHASE")
 lastpur = .Cells(Rows.Count, "A").End(xlUp).Row
 purarr = .Range(.Cells(1, 1), .Cells(lastpur, 5))
End With

With Worksheets("RETURNS")
 lastret = .Cells(Rows.Count, "A").End(xlUp).Row
 retarr = .Range(.Cells(1, 1), .Cells(lastret, 5))
End With

With Worksheets("SALES")
 lastsal = .Cells(Rows.Count, "A").End(xlUp).Row
 salarr = .Range(.Cells(1, 1), .Cells(lastsal, 6))
End With

With Worksheets("SAL1")
 lastS1 = .Cells(Rows.Count, "A").End(xlUp).Row
 S1arr = .Range(.Cells(1, 1), .Cells(lastS1, 5))
End With

With Worksheets("REPORT")
 lastrep = .Cells(Rows.Count, "B").End(xlUp).Row
 reparr = .Range(.Cells(1, 2), .Cells(lastrep, 4))
 outarr = .Range(.Cells(1, 11), .Cells(lastrep, 12))

' load dictionary
   For i = 3 To UBound(reparr, 1)
      tt = Trim(reparr(i, 1)) & Trim(reparr(i, 2)) & Trim(reparr(i, 3)) ' concatenate columns B,C and D
      Dic(tt) = i  ' add them all to the dictionary
   Next i
  
For j = 2 To lastpur
     tp = Trim(purarr(j, 2)) & Trim(purarr(j, 3)) & Trim(purarr(j, 4)) ' concatenate columns B,C and D
       If Dic.exists(tp) Then
       outarr(Dic(tp), 1) = purarr(j, 5)
       End If
Next j
For j = 1 To lastret
     tp = retarr(j, 2) & retarr(j, 3) & retarr(j, 4) ' concatenate columns B,C and D
     If Dic.exists(tp) Then
     outarr(Dic(tp), 1) = outarr(Dic(tp), 1) + retarr(j, 5)
     End If
Next j

For j = 1 To lastsal
     tp = salarr(j, 2) & salarr(j, 3) & salarr(j, 4) ' concatenate columns B,C and D
       If Dic.exists(tp) Then
       outarr(Dic(tp), 1) = outarr(Dic(tp), 1) + salarr(j, 6)
       outarr(Dic(tp), 2) = salarr(j, 5)
       End If
Next j

For j = 1 To lastS1
     tp = S1arr(j, 2) & S1arr(j, 3) & S1arr(j, 4) ' concatenate columns B,C and D
       If Dic.exists(tp) Then
       outarr(Dic(tp), 2) = outarr(Dic(tp), 2) + S1arr(j, 5)
       End If
Next j
 .Range(.Cells(1, 11), .Cells(lastrep, 12)) = outarr
End With
End Sub
 
Upvote 0
thanks for your trying , but it just bring the values form sheet purchase without summing from the others sheets, also some items are missed . the code doesn't bring all of the values and summing from the others sheets .
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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