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
|
Sub copie2()
Dim Plage As Range
Dim Cel As Range
Dim Lig As Long
Dim I As Long
'argument "L" à 2 pour ne pas prendre en compte la première ligne
Set Plage = DefPlage(Worksheets("resultat"), 2, 1)
With Worksheets("SAUVERGARDE")
'recherche la première ligne vide
Lig = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
'inscrit la valeur servant d'ID (si c'est ce qu'il faut ?)
.Cells(Lig, 1) = Lig - 1
'pour éviter la colonne ID (A)
I = 1
'le parcour de la plage se fait de haut en bas et de droite à gauche
For Each Cel In Plage.SpecialCells(xlCellTypeConstants)
I = I + 1
.Cells(Lig, I).Value = Cel.Value
Next Cel
End With
End Sub
Function DefPlage(Fe As Worksheet, Optional L As Long = 1, Optional C As Long = 1) As Range
On Error GoTo Fin
With Fe
Set DefPlage = .Range(.Cells(L, C), _
.Cells(.Cells.Find("*", .[A1], -4123, , _
1, 2).Row, .Cells.Find("*", .[A1], -4123, , _
2, 2).Column))
End With
Exit Function
Fin:
Set DefPlage = Nothing
End Function |
Partager