1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Sub Filtre()
'
' Filtre Macro
'
'
Dim Cell As Range
'
Range("6:6").Select
For Each Cell In Selection
If Cell.Value <> "" Then
If Cell = "abcd" Then
Set Cell = Cell.Offset(x, y)
Range(Cell.Offset(4, 0), Cell.Offset(22, 4)).Select
ActiveWorkbook.Worksheets("feuill1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("feuill1").Sort.SortFields.Add Key:=Cell.Offset(4, 0) _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("feuill1").Sort.SortFields.Add Key:=Cell.Offset(4, 1) _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("feuill1").Sort
.SetRange Range(Cell.Offset(4, 0), Cell.Offset(22, 4))
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End If
Next Cell
End Sub |
Partager