Bonjour je m'adresse à vous les spécialiste ou amateur du VBA
j'ai un petit problème, j'ai un fichier excel qui contient plusieur feuilles je voudrai copier une plage des cellules (a7:a20) et sauter 34 lignes puis copier la plage (a41:a54) etc.... jusu'au la ligne 17000.
j'ai reussi à faire une macro dont les détails ci-après, cette macro est tres lente dans son execution puisque je n'ai pas pu copier la plage, j'ai copier ligne par ligne
c'est très long ....
merci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 Public Sub m1() h = 2 For I = 7 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m2() h = 3 For I = 8 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m3() h = 4 For I = 9 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m4() h = 5 For I = 10 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m5() h = 6 For I = 11 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m6() h = 7 For I = 12 To 1700 Step 34 Sheets("bltar").Range("D" & I).copy Sheets("valtar").Range("B" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m7() h = 8 For I = 13 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m8() h = 9 For I = 14 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m9() h = 10 For I = 15 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m10() h = 11 For I = 16 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m11() h = 12 For I = 17 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m12() h = 13 For I = 18 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m13() h = 14 For I = 19 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Public Sub m14() h = 15 For I = 20 To 1700 Step 34 Sheets("bltar").Range("A" & I).copy Sheets("valtar").Range("D" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("b" & I).copy Sheets("valtar").Range("G" & h).PasteSpecial Paste:=xlValues Sheets("bltar").Range("E" & I).copy Sheets("valtar").Range("H" & h).PasteSpecial Paste:=xlValues Application.CutCopyMode = False h = h + 14 Next End Sub Sub mymacros() m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 m13 m14 End Sub
Partager