1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Sub copiage()
Dim Tbl, x As Integer, dl As Integer, dc As Integer, NbG17 As Integer, y As Integer, z As Integer
With Sheets("Feuil1")
dl = .Range("A" & .Rows.Count).End(xlUp).Row
dc = .Cells(1, .Columns.Count).End(xlToLeft).Column
NbG17 = WorksheetFunction.CountIf(.Range("A2:A" & dl), .Range("G17")) 'sur ton exemple c'est G17 et non G16
ReDim Tbl(1 To NbG17, 1 To dc) 'pour nombre de colonnes variables
y = 0
For x = 2 To dl
If .Range("A" & x) = .Range("G17") Then
y = y + 1
For z = 1 To dc
Tbl(y, z) = .Cells(x, z)
Next z
End If
Next x
Sheets("Feuil2").Range("C8").Resize(UBound(Tbl), dc) = Tbl
End With
End Sub |
Partager