abdo meghari
Well-known Member
- Joined
- Aug 3, 2021
- Messages
- 651
- Office Version
- 2019
hi
I have two sheets (report1,report2) they should match COL B,C,D with sheet REPORTS also COL B,C,D if the data are matched then should summing the values between sheets (report1,report2) if there are items are repeated and put the values after insert three columns in COLS ARRIVES, SALES but the col STOCK should calculate by formula when insert the columns . so every month I insert three columns then it should with same borders and formatting and the formulas last thing is more complicated if there are any items in COL B,C,D are existed in sheets(report1,report2) but not existed in sheet reports then should match based on COL A and add it to sheet reports as highlighted by red
report1
report2
reports
when I run macro should insert three columns every time
I have two sheets (report1,report2) they should match COL B,C,D with sheet REPORTS also COL B,C,D if the data are matched then should summing the values between sheets (report1,report2) if there are items are repeated and put the values after insert three columns in COLS ARRIVES, SALES but the col STOCK should calculate by formula when insert the columns . so every month I insert three columns then it should with same borders and formatting and the formulas last thing is more complicated if there are any items in COL B,C,D are existed in sheets(report1,report2) but not existed in sheet reports then should match based on COL A and add it to sheet reports as highlighted by red
report1
REPORT.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | CTG | BRAND | TYPE | ORIGIN | arrive | sale | ||
2 | LVR | 1200R20 | G580 | JAP | 20 | 5 | ||
3 | LVR | 13R22.5 | R187 | JAP | 100 | |||
4 | LVR | 1400R20 | VSJ | JAP | 20 | |||
5 | PSR | 175/70R14 | EP150 | THI | 70 | |||
6 | PSR | 185/65R14 | EP150 | INDO | 120 | |||
7 | PSR | 185/65R15 | T005 | INDO | 30 | |||
8 | LSR2 | 195R14C | 613V | JAP | 50 | |||
report1 |
report2
REPORT.xlsm | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | CTG | BRAND | TYPE | ORIGIN | arrive | sale | ||
2 | LVR | 1200R20 | G580 | JAP | 134 | 100 | ||
3 | LVR | 1200R24 | G580 | JAP | 45 | 30 | ||
4 | LSR2 | 155R12C | R623 | JAP | 20 | |||
5 | LSR2 | 155R12C | R624 | INDO | 50 | |||
report2 |
reports
REPORT.xlsm | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | JAN | ||||||||
2 | Category | brand | type | origin | ARRIVE | SALE | STOCK | ||
3 | PSR | 185/65R14 | TEC | THI | 12 | 12 | |||
4 | 185/65R14 | EP150 | INDO | - | |||||
5 | 185/65R15 | TC10 | INDO | - | |||||
6 | 185/65R15 | T005 | INDO | - | |||||
7 | 185/65R15 | T01 | JAP | - | |||||
8 | 185/65R15 | B250 | JAP | - | |||||
9 | 195/60R15 | AR20 | INDO | - | |||||
10 | 195/60R15 | EP150 | THI | 10 | 10 | ||||
11 | 195/60R15 | T001 | JAP | - | |||||
12 | TTL | 22 | - | 22 | |||||
13 | LSR1 | 215/45R17 | GR90 | THI | - | ||||
14 | 215/45R17 | RE001 | JAP | - | |||||
15 | 215/45R17 | T001 | JAP | - | |||||
16 | 215/50R17 | EP300 | THI | - | |||||
17 | 215/55R17 | AR20 | INDO | - | |||||
18 | 215/55R17 | GR90 | INDO | - | |||||
19 | 215/55R17 | T001 | JAP | - | |||||
20 | 215/55R17 | T005 | JAP | - | |||||
21 | TTL | - | - | - | |||||
22 | LSR2 | 650R16 | R230 | 10 | 8 | 2 | |||
23 | 700R16 | R230 | 12PR | - | |||||
24 | 750R16 | R230 | - | ||||||
25 | 155R12C | R624 | INDO | - | |||||
26 | 155R12C | R623 | JAP | - | |||||
27 | 165R13C | R624 | INDO | - | |||||
28 | 185R14C | 613V | JAP | - | |||||
29 | 185R14C | R624 | INDO | - | |||||
30 | 195R14C | R624 | INDO | - | |||||
31 | 195R14C | 613V | JAP | - | |||||
32 | 195R14C | R623 | THI | - | |||||
33 | 205R14C | 613V | JAP | - | |||||
34 | 205R14C | R624 | INDO | - | |||||
35 | 215R14C | R624 | INDO | 12 | 12 | ||||
36 | TTL | 22 | 8 | 14 | |||||
37 | Dueler | 825R16 | R180 | JAP | |||||
38 | TTL | - | - | - | |||||
39 | 1400R20 | R180 | JAP | 13 | 13 | ||||
40 | 11R22.5 | R187 | JAP | - | |||||
41 | 12R22.5 | R187 | JAP | - | |||||
42 | 13R22.5 | R187 | 18PR | - | |||||
43 | 275/70R22.5 | R294 | JAP | - | |||||
44 | 295/80R22.5 | M840 | JAP | - | |||||
45 | 315/80R22 JAP | R184 | 18PR | - | |||||
46 | 315/80R22.5 | R294 | JAP | - | |||||
47 | 315/80R22 THI | R184 | 18PR | - | |||||
48 | 315/80R22 | R152 | JAP | - | |||||
49 | LVR | 315/80R22 | G580 | INDO | - | ||||
50 | 425/65R22.5 | R164 | INDO | 20 | 20 | ||||
51 | 385/65R22.5 | R164 | THI | - | |||||
52 | 385/65R22.5 | R164 | JAP | - | |||||
53 | 445/65R22.5 | R164 | JAP | - | |||||
54 | 325/95R24 | G582 | JAP | - | |||||
55 | TTL | 33 | - | 33 | |||||
reports |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E12:G12 | E12 | =SUM(E3:E11) |
E21:G21 | E21 | =SUM(E13:E20) |
G39:G54,G22:G35,G13:G20,G3:G11 | G3 | =E3-F3 |
E36:G36 | E36 | =SUM(E22:E35) |
E38:G38 | E38 | =SUM(E37:E37) |
E55:G55 | E55 | =SUM(E39:E54) |
when I run macro should insert three columns every time
REPORT.xlsm | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | JAN | FEB | ||||||||||
2 | Category | brand | type | origin | ARRIVE | SALE | STOCK | ARRIVE | SALE | STOCK | ||
3 | PSR | 175/70R14 | EP150 | THI | - | 70 | 70 | |||||
4 | 185/65R14 | TEC | THI | 12 | 12 | 12 | ||||||
5 | 185/65R14 | EP150 | INDO | - | 120 | 120 | ||||||
6 | 185/65R15 | TC10 | INDO | - | - | |||||||
7 | 185/65R15 | T005 | INDO | - | 30 | 30 | ||||||
8 | 185/65R15 | T01 | JAP | - | - | |||||||
9 | 185/65R15 | B250 | JAP | - | - | |||||||
10 | 195/60R15 | AR20 | INDO | - | - | |||||||
11 | 195/60R15 | EP150 | THI | 10 | 10 | 10 | ||||||
12 | 195/60R15 | T001 | JAP | - | - | |||||||
13 | TTL | 22 | - | 22 | 220 | - | 242 | |||||
14 | LSR1 | 215/45R17 | GR90 | THI | - | - | ||||||
15 | 215/45R17 | RE001 | JAP | - | - | |||||||
16 | 215/45R17 | T001 | JAP | - | - | |||||||
17 | 215/50R17 | EP300 | THI | - | - | |||||||
18 | 215/55R17 | AR20 | INDO | - | - | |||||||
19 | 215/55R17 | GR90 | INDO | - | - | |||||||
20 | 215/55R17 | T001 | JAP | - | - | |||||||
21 | 215/55R17 | T005 | JAP | - | - | |||||||
22 | TTL | - | - | - | - | - | - | |||||
23 | Dueler | 650R16 | R230 | 10 | 8 | 2 | 2 | |||||
24 | 700R16 | R230 | 12PR | - | - | |||||||
25 | 750R16 | R230 | - | - | ||||||||
26 | 155R12C | R624 | INDO | - | 50 | 50 | ||||||
27 | 155R12C | R623 | JAP | - | 20 | 20 | ||||||
28 | 165R13C | R624 | INDO | - | - | |||||||
29 | 185R14C | 613V | JAP | - | - | |||||||
30 | 185R14C | R624 | INDO | - | - | |||||||
31 | 195R14C | R624 | INDO | - | - | |||||||
32 | 195R14C | 613V | JAP | - | 50 | 50 | ||||||
33 | 195R14C | R623 | THI | - | - | |||||||
34 | 205R14C | 613V | JAP | - | - | |||||||
35 | 205R14C | R624 | INDO | - | - | |||||||
36 | 215R14C | R624 | INDO | 12 | 12 | 12 | ||||||
37 | TTL | 22 | 8 | 14 | 120 | - | 134 | |||||
38 | 825R16 | R180 | JAP | - | - | - | - | - | - | |||
39 | TTL | - | - | - | - | - | - | |||||
40 | LVR | 1200R20 | G580 | JAP | - | 154 | 105 | 49 | ||||
41 | 1400R20 | R180 | JAP | 13 | 13 | 20 | 33 | |||||
42 | 11R22.5 | R187 | JAP | - | - | |||||||
43 | 12R22.5 | R187 | JAP | - | - | |||||||
44 | 13R22.5 | R187 | JAP | - | 100 | 100 | ||||||
45 | 1200R24 | G580 | JAP | - | 45 | 30 | 15 | |||||
46 | 275/70R22.5 | R294 | JAP | - | - | |||||||
47 | 295/80R22.5 | M840 | JAP | - | - | |||||||
48 | 315/80R22 JAP | R184 | 18PR | - | - | |||||||
49 | 315/80R22.5 | R294 | JAP | - | - | |||||||
50 | 315/80R22 THI | R184 | 18PR | - | - | |||||||
51 | 315/80R22 | R152 | JAP | - | - | |||||||
52 | 315/80R22 | G580 | INDO | - | - | |||||||
53 | 425/65R22.5 | R164 | INDO | 20 | 20 | 20 | ||||||
54 | 385/65R22.5 | R164 | THI | - | - | |||||||
55 | 385/65R22.5 | R164 | JAP | - | - | |||||||
56 | 445/65R22.5 | R164 | JAP | - | - | |||||||
57 | 325/95R24 | G582 | JAP | - | - | |||||||
58 | TTL | 33 | - | 33 | 319 | 135 | 217 | |||||
expected result |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E13:J13 | E13 | =SUM(E3:E12) |
E22:J22 | E22 | =SUM(E14:E21) |
E37:J37 | E37 | =SUM(E23:E36) |
E39:J39 | E39 | =SUM(E38:E38) |
G40:G57,G38,G23:G36,G14:G21,G3:G12 | G3 | =E3-F3 |
J40:J57,J38,J23:J36,J14:J21,J3:J12 | J3 | =G3+H3-I3 |
E58:J58 | E58 | =SUM(E40:E57) |