macro tri automatique

Jec

XLDnaute Nouveau
Bonjour,

Je voudrais savoir comment modifier un peu ce code. Car quand je lance on voit les actions car c est une macro que jai record. Comment rendre les actions plus discrete par exemple ne pas voir la selection du tableau etc.
Et comment supprimer l effet de bouche?

Sub macro_tri()

ActiveWorkbook.Worksheets("prod").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("prod").Sort.SortFields.Add Key:=Range("H6:H1000") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("prod").Sort.SortFields.Add Key:=Range("M6:M1000") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("prod").Sort
.SetRange Range("A5:V1000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("K6:K1000").Select
Selection.ClearContents
End Sub
 

jpb388

XLDnaute Accro
Bonjour à tous
essayes ceci
Code:
Sub macro_tri()
    Application.ScreenUpdating = False
    With Worksheets("prod").Sort
        .SortFields.Clear
        .SortFields.Add Worksheets("prod").Range("H6:H1000"), xlSortOnValues, xlAscending, xlSortNormal
        .SortFields.Add Worksheets("prod").Range("M6:M1000"), xlSortOnValues, xlAscending, xlSortNormal
        .SetRange Worksheets("prod").Range("A5:V1000")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Range("K6:K1000").ClearContents
    Application.ScreenUpdating = True
End Sub
si Range("K6:K1000").ClearContents concerne Worksheets("prod") alors tu mets Worksheets("prod").Range("K6:K1000").ClearContents si cela concerne la feuille active tu laisse comme cela
 

Statistiques des forums

Discussions
312 196
Messages
2 086 101
Membres
103 117
dernier inscrit
augustin.morille