Optimisation code avec boucle
Bonjour;
Je me remet depuis peu sur excel VBA
Je cherche a créer une boucle d'un userform sur une feuille excel afin de copier plusieurs lignes à la suite suivant les combobox renseignés
ça fonctionne avec le code ci dessous mais je pense qu'il y a plus simple avec une boucle d'autant que j'ai une centaine de combobox a renseigner, si quelqu’un peut m'aider ?
Merci d'avance:calim2:
Code:
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
|
With Sheets("Data")
.Range("a" & i + 1).Value = .Range("a" & i).Value + 1
.Range("b" & i + 1).Value = ComboBox1.Value
.Range("c" & i + 1).Value = ComboBox101.Value
.Range("d" & i + 1).Value = ComboBox121.Value
.Range("e" & i + 1).Value = ComboBox141.Value
.Range("f" & i + 1).Value = ComboBox161.Value
.Range("a" & i + 2).Value = .Range("a" & i).Value + 2
.Range("b" & i + 2).Value = ComboBox2.Value
.Range("c" & i + 2).Value = ComboBox102.Value
.Range("d" & i + 2).Value = ComboBox122.Value
.Range("e" & i + 2).Value = ComboBox142.Value
.Range("f" & i + 2).Value = ComboBox162.Value
.Range("a" & i + 3).Value = .Range("a" & i).Value + 3
.Range("b" & i + 3).Value = ComboBox3.Value
.Range("c" & i + 3).Value = ComboBox103.Value
.Range("d" & i + 3).Value = ComboBox123.Value
.Range("e" & i + 3).Value = ComboBox143.Value
.Range("f" & i + 3).Value = ComboBox163.Value
etc.
End With |
A vous lire
Phileas