Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

faire un tri sur toutes mes feuilles sauf la feuille 1 et feuille2

1 réponse
Avatar
magic-dd
bonsoir =E0 tous

j'ai cree cette macro pour trier toutesmes feuilles sauf la 1 et 2
mais cela ne marche que sur la feuille active

merci de m'aider dans la correction de ce code



Sub test()

For Each Sh In ActiveWorkbook.Sheets
If Sh.CodeName <> "Feuil1" And Sh.CodeName <> "Feuil2" Then

Columns("A:P").Select
Selection.Sort Key1:=3DRange("B2"),
Order1:=3DxlAscending, Header:=3DxlYes, _
OrderCustom:=3D1, MatchCase:=3DFalse,
Orientation:=3DxlTopToBottom, _
DataOption1:=3DxlSortNormal
Range("A1").Select

End If
Next Sh
End Sub

1 réponse

Avatar
LSteph
Bonsoir Magic,

ainsi peut-être:

Sub test()
Dim Sh As Worksheet
For Each Sh In ActiveWorkbook.Sheets
If Sh.CodeName <> "Feuil1" And Sh.CodeName <> "Feuil2" Then
With Sh
.Activate
.Columns("A:P").Sort Key1:=Range("B2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:úlse, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
.[a1].Activate
End With
End If
Next Sh
End Sub



'lSteph

magic-dd a écrit :
bonsoir à tous

j'ai cree cette macro pour trier toutesmes feuilles sauf la 1 et 2
mais cela ne marche que sur la feuille active

merci de m'aider dans la correction de ce code



Sub test()

For Each Sh In ActiveWorkbook.Sheets
If Sh.CodeName <> "Feuil1" And Sh.CodeName <> "Feuil2" Then

Columns("A:P").Select
Selection.Sort Key1:=Range("B2"),
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:úlse,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select

End If
Next Sh
End Sub