Sub test_group_2()
[O11:Z65000].ClearContents 'efface
For lig = 11 To [J65000].End(3).Row
col = (Cells(lig, 10) * 5) + 10
col2 = (Cells(lig, 11) * 5) + 10
Range("O" & lig & ":S" & lig).Value = Range(Cells(2, col), Cells(2, col + 4)).Value
Range("V" & lig & ":Z" & lig).Value = Range(Cells(2, col2), Cells(2, col2 + 4)).Value
Next
End Sub
Bonsoir Bruno
Bein, comme je ne voyais pas ce qu'il voulais faire au juste, j'ai pensé au fameux tablo(). Et comme moi je n'ai toujours pas de maîtrise, j'ai laissé la main (pas la mienne hein!!).
Sub test_group_2()
Dim MyArray(4) As Variant
MyArray(1) = Range("O2:S2")
MyArray(2) = Range("T2:X2")
MyArray(3) = Range("Y2:AC2")
MyArray(4) = Range("AD2:AH2")
[O11:Z65000].ClearContents 'efface
For lig = 11 To [J65000].End(3).Row 'boucle de 11 en bas de col J
Range("O" & lig & ":S" & lig).Value = MyArray(Cells(lig, 10)) 'N° de myarray
Range("V" & lig & ":Z" & lig).Value = MyArray(Cells(lig, 11))
Next
End Sub
Voici qui est plus proche et avec tes MyArray,
Possibilité de faire une boucle pour indiquer les myarray() mais pour 4 lignes .... pas la peine
Bruno
VB:Sub test_group_2() Dim MyArray(4) As Variant MyArray(1) = Range("O2:S2") MyArray(2) = Range("T2:X2") MyArray(3) = Range("Y2:AC2") MyArray(4) = Range("AD2:AH2") [O11:Z65000].ClearContents 'efface For lig = 11 To [J65000].End(3).Row 'boucle de 11 en bas de col J Range("O" & lig & ":S" & lig).Value = MyArray(Cells(lig, 10)) 'N° de myarray Range("V" & lig & ":Z" & lig).Value = MyArray(Cells(lig, 11)) Next End Sub
Yes,
[A65000].end(3).row le 3 indique XlUp
exemple pour écrire aprés la dernière ligne dans une BD on utilise souvent
ligne=[A65000].end(3).row+1
les [XFD1] .End(xlToLeft).column et autres peuvent être remplacé par leur N°
Ce dernier code renvoie le N° de la dernière colonne de ligne 1
Bruno