Re : VBA tri personnalisé sur une plage variable
Bonjour,
Ci-joint exemple de fichier + macro incluse.
Je souhaite effectuer un double tri :
1/ tri personnalisé sur la colonne B avec dans l'ordre : Moyen,Grand,Petit
2/ tri ascendant sur la colonne C.
Voici le résultat de l’enregistreur macro :
Sub Tri_personnalise()
ActiveWorkbook.Worksheets("Ville").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Ville").Sort.SortFields.Add Key:=Range("B2:B16"), _
SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"Moyen,Grand,Petit", DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Ville").Sort.SortFields.Add Key:=Range("C2:C16"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Ville").Sort
.SetRange Range("A1:C16")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Le problème est que le nombre de ligne varie.
Comment définir la plage variable (en rouge dans ma macro) ?
Merci.