Dim Zone As Range
Sub MesZones() 'recherche des zones à trier
With Sheets("STOCK")
deb = 8
While .Cells(deb, 2) <> ""
'Set Zone = .Range(.Cells(deb + 1, 2), .Cells(deb + .Cells(deb, 2).CurrentRegion.Rows.Count - 1, .Cells(deb, 2).CurrentRegion.Columns.Count + 1))
Set Zone = .Range(.Cells(deb + 1, 3), .Cells(deb + .Cells(deb, 3).CurrentRegion.Rows.Count - 1, .Cells(deb, 2).CurrentRegion.Columns.Count + 1))
Zone.Select
deb = .Cells(deb, 3).CurrentRegion.Rows.Count + 3 + deb
Call trie(Zone)
Wend
'Retour début du tableau
.Cells(8, 1).Select
End With
End Sub
Sub trie(Zone)
'Zone.Sort key1:=Zone.Columns(1), Orientation:=xlAscending
With ActiveSheet.Sort
With .SortFields
.Clear
' Trier sur le produit
.Add2 Key:=Zone.Columns(1), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
' et trier sur la DLC
.Add2 Key:=Zone.Columns(7), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
.SetRange Zone
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub