abdo meghari
Well-known Member
- Joined
- Aug 3, 2021
- Messages
- 573
- Office Version
- 2019
Hello
I got this code from Peter_Ss he helped me in previous thread
based on the code will copy columns (B,C,D) and the last three columns based on headers (ARRIVES,SALES,STOCK) which locates under the month
the last three columns will issued every month . so when copy it depends on headers (ARRIVES,SALES,STOCK) which locates under the month
now what I want when copy the last three columns (ARRIVES,SALES,STOCK) should just contain values one of two columns (ARRIVES,SALES) I mean if they're two both contain value 0 then should not copy data columns (B,C,D) & last three columns (ARRIVES,SALES,STOCK)
just copy columns (B,C,D) & last three columns (ARRIVES,SALES,STOCK) if one of two columns (ARRIVES,SALES) don't contain 0 . but this condition should not apply in row contains TTL as in column B
last thing the data in row will increase for 2300 rows and the columns will increase for 50 columns .
any idea to update code or alternitave please?
before
my data are 2000 rows and will increase overtime
after
I got this code from Peter_Ss he helped me in previous thread
VBA Code:
Sub Copy_Columns()
Sheets("output").UsedRange.EntireColumn.Delete
With Sheets("In & Out Balance")
Intersect(.UsedRange, Union(.Columns("B:D"), .Columns(.Cells(2, Columns.Count).End(xlToLeft).Column - 2).Resize(, 3))).Copy
End With
With Sheets("output")
.Range("A1").PasteSpecial Paste:=xlPasteValues
.Range("A1").PasteSpecial Paste:=xlPasteFormats
.Columns("E:G").NumberFormat = "#,##0.00"
.UsedRange.Columns.AutoFit
End With
End Sub
the last three columns will issued every month . so when copy it depends on headers (ARRIVES,SALES,STOCK) which locates under the month
now what I want when copy the last three columns (ARRIVES,SALES,STOCK) should just contain values one of two columns (ARRIVES,SALES) I mean if they're two both contain value 0 then should not copy data columns (B,C,D) & last three columns (ARRIVES,SALES,STOCK)
just copy columns (B,C,D) & last three columns (ARRIVES,SALES,STOCK) if one of two columns (ARRIVES,SALES) don't contain 0 . but this condition should not apply in row contains TTL as in column B
last thing the data in row will increase for 2300 rows and the columns will increase for 50 columns .
any idea to update code or alternitave please?
before
(5).xlsx | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | |||
1 | Oct | Nov | Dec | ||||||||||||
2 | Category | Size | Pattern | Origin | Arrived | Sales | Stock | Arrived | Sales | Stock | Arrived | Sales | Stock | ||
3 | PSR (LRD) | 175/70R13 | B25 | INDO | 200 | 16 | 184 | 5 | 179 | 11 | 190 | ||||
4 | 175/70R13 | EP150 | THI | - | - | - | - | - | 10 | - | - | 10 | |||
5 | 185/70R13 | EP150 | INDO | - | - | - | - | - | - | - | 1 | -1 | |||
6 | 175/65R14 | EP150 | INDO | 20 | - | 20 | 10 | - | 30 | 11 | 10 | 31 | |||
7 | 175/70R14 | EP150 | THI | 30 | - | 30 | - | - | - | - | - | - | |||
8 | 175/70R14 | MY02 | THI | 110 | - | 110 | - | 5 | 105 | - | - | 105 | |||
9 | 185/65R14 | TEC | THI | 120 | - | 120 | - | - | 120 | - | - | 120 | |||
10 | 185/65R14 | EP150 | INDO | 200 | - | 200 | 22 | 3 | 219 | 33 | - | 252 | |||
11 | 185/65R14 | 150EZ | INDO | - | - | - | 33 | - | 33 | - | - | 33 | |||
12 | 185/65R15 | TC10 | INDO | - | - | - | 33 | - | 33 | - | - | 33 | |||
13 | 185/65R15 | T005 | INDO | - | - | - | 45 | - | 45 | - | - | 45 | |||
14 | 185/65R15 | T01 | JAP | 22 | 12 | 10 | - | - | 10 | - | - | 10 | |||
15 | 185/65R15 | B250 | JAP | - | - | - | - | - | - | - | - | - | |||
16 | 195/60R15 | AR20 | INDO | 11 | - | 11 | - | - | 11 | - | - | 11 | |||
17 | 195/60R15 | EP150 | THI | 22 | 22 | - | - | - | - | 123 | - | 123 | |||
18 | 195/60R15 | T001 | JAP | - | - | - | - | - | - | - | - | - | |||
19 | 195/60R15 | 150EZ | THI | - | - | - | - | - | - | - | - | - | |||
20 | 195/65R15 | MY02 | THI | 234 | - | 234 | - | - | 234 | - | - | 234 | |||
21 | 195/65R15 | EP150 | THI | 444 | - | 444 | - | - | 444 | - | - | 444 | |||
22 | 195/65R15 | EP150 | JAP | 44 | - | 44 | - | - | 44 | - | - | 44 | |||
23 | 195/65R15 | T001 | JAP | 55 | - | 55 | - | - | 55 | 5 | - | 60 | |||
24 | 195/55R16 | EP300 | THI | - | - | - | - | - | - | - | - | - | |||
25 | 205/55R16 | RE003 | THI | - | - | - | - | - | - | - | - | - | |||
26 | 205/65R15 | EP150 | INDO | - | - | - | - | - | - | 5 | - | 5 | |||
27 | 205/65R15 | MY02 | THI | - | - | - | 5 | - | 5 | 5 | - | 10 | |||
28 | 205/65R15 | T01 | JAP | - | - | - | - | - | - | - | - | - | |||
29 | FS 205/65R15 | TZ700 | JAP | - | - | - | - | - | - | - | - | - | |||
30 | 215/65R15 | T005 | INDO | - | - | - | 5 | - | 5 | 5 | 5 | 5 | |||
31 | 205/70R15 | 694 | JAP | - | - | - | 66 | - | 66 | - | - | 66 | |||
32 | 225/75R15C | T697 | INDO | - | - | - | 66 | - | 66 | - | - | 66 | |||
33 | 235/95R15C | D618 | JAP | - | 1 | -1 | - | - | -1 | 1 | - | - | |||
34 | 255/70R15C | D840 | THI | - | - | - | - | - | - | - | - | - | |||
35 | 205R16C | D840 | THI | - | - | - | - | - | - | - | - | - | |||
36 | 205/R16C | D697 | THI | - | - | - | - | - | - | - | - | - | |||
37 | 205/55R16 | AR20 | INDO | - | - | - | - | - | - | - | - | - | |||
38 | 205/55R16 | G3 | JAP | - | - | - | - | - | - | - | - | - | |||
39 | 205/55R16 | T001 | - | - | - | - | - | - | - | - | - | ||||
40 | 205/55R16 | ER300 | POL | - | - | - | - | - | - | - | - | - | |||
41 | 205/60R16 | AR20 | INDO | - | - | - | - | - | - | - | - | - | |||
42 | 205/60R16 | T005 | THI | - | - | - | - | - | - | - | - | - | |||
43 | 205/60R16 | T001 | JAP | - | - | - | - | - | - | - | - | - | |||
44 | 205/65R16 | EP300 | INDO | - | - | - | - | - | - | - | - | - | |||
45 | 205/65R16 | EP30Z | INDO | - | - | - | - | - | - | - | - | - | |||
46 | 265/70R16 | D840 | THI | - | - | - | - | - | - | - | - | - | |||
47 | 275/70R16 | H005 | THI | - | - | - | - | - | - | - | - | - | |||
48 | 275/70R16 | D694 | JAP | - | - | - | - | - | - | - | - | - | |||
49 | LT285/75R16 | AT001 | JAP | - | - | - | - | - | - | - | - | - | |||
50 | TTL | 1512 | 51 | 1461 | 285 | 13 | 1713 | 199 | 16 | 1896 | |||||
51 | PSR (HRD) | 215/45R17 | T001 | JAP | - | - | - | - | - | - | - | - | - | ||
52 | 215/50R17 | EP300 | THI | 34 | - | 34 | - | - | 34 | - | - | 34 | |||
53 | 215/55R17 | GR90 | INDO | 44 | - | 44 | - | - | 44 | - | - | 44 | |||
54 | 215/55R17 | T001 | JAP | - | - | - | - | - | - | - | - | - | |||
55 | 215/55R17 | T005 | JAP | - | - | - | - | - | - | - | - | - | |||
56 | 275/55R20 | ALENZA | JAP | - | - | - | - | - | 12 | 1 | - | 13 | |||
57 | 285/50R20 | DSPORT | - | - | - | - | - | - | 1 | - | 1 | ||||
58 | 275/65R18 | 116H | THI | - | - | - | - | - | - | - | 1 | -1 | |||
59 | 275/65R18 | AL01 | JAP | 22 | - | 22 | 22 | - | 44 | 12 | - | 56 | |||
60 | 285/60R18 | T01 | JAP | 22 | - | 22 | - | - | 22 | - | - | 22 | |||
61 | 285/60R18 | D850 | JAP | 22 | - | 22 | 1 | - | 23 | 1 | - | 24 | |||
62 | 245/40R20 | RE050 | JAP | - | - | - | - | - | - | - | - | - | |||
63 | 265/50R20 | SPORT | JAP | - | - | - | - | - | - | - | - | - | |||
64 | 275/30R20 | RE050 | JAP | - | - | - | - | - | - | - | - | - | |||
65 | 275/40R20 | DHP | JAP | - | - | - | - | - | - | - | - | - | |||
66 | 275/55R20 | D680 | JAP | - | - | - | - | - | - | - | - | - | |||
67 | 285/30R20 | RE0050A | JAP | - | - | - | - | - | - | - | - | - | |||
68 | 315/35R20 | SPORT | JAP | - | - | - | - | - | - | - | - | - | |||
69 | TTL | 144 | - | 144 | 23 | - | 179 | 15 | 1 | 193 | |||||
In & Out Balance |
Cell Formulas | ||
---|---|---|
Range | Formula | |
J3,M51:M68,M3:M49,J57:J68,J51:J55,J8:J49,J5:J6 | J3 | =G3+H3-I3 |
E50:M50 | E50 | =SUM(E3:E49) |
G51:G68,G3:G49 | G3 | =E3-F3 |
E69:M69 | E69 | =SUM(E51:E68) |
my data are 2000 rows and will increase overtime
after
(5).xlsx | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
1 | ITEM | Size | Pattern | Origin | Arrived | Sales | Stock | ||
2 | 1 | 175/70R13 | B25 | INDO | 11 | 190 | |||
3 | 2 | 185/70R13 | EP150 | INDO | - | 1 | -1 | ||
4 | 3 | 175/65R14 | EP150 | INDO | 11 | 10 | 31 | ||
5 | 4 | 185/65R14 | EP150 | INDO | 33 | - | 252 | ||
6 | 5 | 195/60R15 | EP150 | THI | 123 | - | 123 | ||
7 | 6 | 195/65R15 | T001 | JAP | 5 | - | 60 | ||
8 | 7 | 205/65R15 | EP150 | INDO | 5 | - | 5 | ||
9 | 8 | 205/65R15 | MY02 | THI | 5 | - | 10 | ||
10 | 9 | 215/65R15 | T005 | INDO | 5 | 5 | 5 | ||
11 | TTL | 198 | 16 | 675 | |||||
12 | 1 | 275/55R20 | ALENZA | JAP | 1 | - | 13 | ||
13 | 2 | 285/50R20 | DSPORT | 1 | - | 1 | |||
14 | 3 | 275/65R18 | 116H | THI | - | 1 | -1 | ||
15 | 4 | 275/65R18 | AL01 | JAP | 12 | - | 56 | ||
16 | 5 | 285/60R18 | D850 | JAP | 1 | - | 24 | ||
17 | TTL | 15 | 1 | 93 | |||||
output |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E11:G11 | E11 | =SUM(E2:E10) |
E17:G17 | E17 | =SUM(E12:E16) |
Last edited by a moderator: