Bonjour à tous,
Grâce à l'aide du Forum, j'ai pu réaliser une macro afin de copier des colonnes, les regrouper en une seule, puis faire un tri sur cette colonne.
Vous la trouverez dans le fichier joint allégé, et ci-dessous (soyez indulgents, je débute!)
Sub Transfert()
Dim Col%, tc, ligne&, m&, n&
tc = Array(3, 6, 9)
Range("A1:A5000").ClearContents
ligne = 1
For n = 0 To UBound(tc)
Col = tc(n)
For m = 1 To Cells(5000, Col).End(xlUp).Row
If Cells(m, Col) <> 0 Then
Cells(ligne, 1) = Cells(m, Col)
ligne = ligne + 1
End If
Next m
Next n
Columns("A:A").Select
ActiveWorkbook.Worksheets("Plan").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Plan").Sort.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Plan").Sort
.SetRange Range("A1:A500")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
J'ai un soucis de rapidité.
En effet, mon fichier final, comporte plus de trente colonne et 1200 lignes.
Alors ça rame un peu.
Je pense que c'est du à ma macro qui fonctionne mais rame, et qu'il doit y avoir un moyen d'accélérer tout ça, mais je sêche !
Merci de m'apporter vos lumières.
Cordialement
Joël
Grâce à l'aide du Forum, j'ai pu réaliser une macro afin de copier des colonnes, les regrouper en une seule, puis faire un tri sur cette colonne.
Vous la trouverez dans le fichier joint allégé, et ci-dessous (soyez indulgents, je débute!)
Sub Transfert()
Dim Col%, tc, ligne&, m&, n&
tc = Array(3, 6, 9)
Range("A1:A5000").ClearContents
ligne = 1
For n = 0 To UBound(tc)
Col = tc(n)
For m = 1 To Cells(5000, Col).End(xlUp).Row
If Cells(m, Col) <> 0 Then
Cells(ligne, 1) = Cells(m, Col)
ligne = ligne + 1
End If
Next m
Next n
Columns("A:A").Select
ActiveWorkbook.Worksheets("Plan").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Plan").Sort.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Plan").Sort
.SetRange Range("A1:A500")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
J'ai un soucis de rapidité.
En effet, mon fichier final, comporte plus de trente colonne et 1200 lignes.
Alors ça rame un peu.
Je pense que c'est du à ma macro qui fonctionne mais rame, et qu'il doit y avoir un moyen d'accélérer tout ça, mais je sêche !
Merci de m'apporter vos lumières.
Cordialement
Joël