je suis probablement fatigué... mais je bloque sur un code depuis quelques heures.
Je souhaite copier une cellule dans une range sur une autre feuille plusieurs fois à la suite.
Pour l'instant j'ai le code suivant:
VB:
Dim x As Long
Dim y As Long
Dim z As Long
Dim LastRPreTCD As Long
Dim LastCData As Long
LastRPreTCD = Sheets("PRETCD").Cells(Sheets("PRETCD").Rows.Count, "A").End(xlUp).Row
LastCData = Sheets("DATA").Cells(1, Sheets("DATA").Columns.Count).End(xlToLeft).Column
x = (LastCData - 1) * (LastRPreTCD - 1)
For z = 2 To LastCData
For y = 2 To x Step 21
Sheets("DATA").Cells(1, z).Copy Sheets("PRETCD").Range(Cells(y, 12), Cells(y + 22, 12))
Next
Next
Si quelqu'un avait la bonté d'éclairer ma route, je vous en serai reconnaissant.
Sub TEST()
Dim x As Long
Dim y As Long
Dim z As Long
Dim LastRPreTCD As Long
Dim LastCData As Long
LastRPreTCD = Sheets("PRETCD").Cells(Sheets("PRETCD").Rows.Count, "A").End(xlUp).Row
LastCData = Sheets("DATA").Cells(1, Sheets("DATA").Columns.Count).End(xlToLeft).Column
x = (LastCData - 1) * (LastRPreTCD - 1)
n = 2
For z = 2 To LastCData
For y = n To x
Sheets("DATA").Cells(1, z).Copy Sheets("PRETCD").Range(Cells(y, 12), Cells(y + 22, 12))
Next
n = n + 21
Next
End Sub
Sub TEST()
Dim x As Long
Dim y As Long
Dim z As Long
Dim LastRPreTCD As Long
Dim LastCData As Long
LastRPreTCD = Sheets("PRETCD").Cells(Sheets("PRETCD").Rows.Count, "A").End(xlUp).Row
LastCData = Sheets("DATA").Cells(1, Sheets("DATA").Columns.Count).End(xlToLeft).Column
n = 2
For z = 2 To LastCData
For y = n To LastRPreTCD
Sheets("DATA").Cells(1, z).Copy Sheets("PRETCD").Cells(y, 12)
Next
n = n + 21
Next
End Sub
Sub Test()
Dim y&
y = 1600
MsgBox Range(Cells(y, 12), Cells(y, 12)).Address(0, 0) 'bizarre comme syntaxe, non ? ;-)
MsgBox Cells(y, 12).Address(0, 0)
MsgBox Cells(y, "L").Address(0, 0)
MsgBox Range("L" & y).Address(0, 0)
End Sub
Sub Test()
Dim y&
y = 1600
MsgBox Range(Cells(y, 12), Cells(y, 12)).Address(0, 0) 'bizarre comme syntaxe, non ? ;-)
MsgBox Cells(y, 12).Address(0, 0)
MsgBox Cells(y, "L").Address(0, 0)
MsgBox Range("L" & y).Address(0, 0)
End Sub