Bonjour,
J'ai un petit soucis sur une macro.
Je copie des données de la feuille 2 et je les colle dans la feuille 3. Jusque là, tout fonctionne.
Je voudrais pouvoir balayer les 122 colonnes à partir de la colonne C la feuille 3
Le début de la macro est ok :
Sub Macro1()
Sheets("Feuil2").Select
For j = 3 To 3
i = 122
While (Cells(i - 1, j).Value = 0)
i = i - 1
Wend
k = i - 1
Sheets("Feuil2").Select
Cells(k, j).Select
Range(Selection, Selection.End(xlUp)).Select
Range("C2:C26").Select
Range("C26").Activate
Selection.Copy
Sheets("Feuil3").Select
Cells(2, j).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Feuil3").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil3").Sort.SortFields.Add Key:=Range("C2"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
A partir de là, ça coince...
With ActiveWorkbook.Worksheets("Feuil3").Sort
.SetRange Range(Cells(2,"& j &"):Cells(130, "& j &"))
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Next j
End Sub
Une idée?
J'ai un petit soucis sur une macro.
Je copie des données de la feuille 2 et je les colle dans la feuille 3. Jusque là, tout fonctionne.
Je voudrais pouvoir balayer les 122 colonnes à partir de la colonne C la feuille 3
Le début de la macro est ok :
Sub Macro1()
Sheets("Feuil2").Select
For j = 3 To 3
i = 122
While (Cells(i - 1, j).Value = 0)
i = i - 1
Wend
k = i - 1
Sheets("Feuil2").Select
Cells(k, j).Select
Range(Selection, Selection.End(xlUp)).Select
Range("C2:C26").Select
Range("C26").Activate
Selection.Copy
Sheets("Feuil3").Select
Cells(2, j).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Feuil3").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Feuil3").Sort.SortFields.Add Key:=Range("C2"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
A partir de là, ça coince...
With ActiveWorkbook.Worksheets("Feuil3").Sort
.SetRange Range(Cells(2,"& j &"):Cells(130, "& j &"))
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Next j
End Sub
Une idée?