Option Explicit
Dim w As Worksheet
Dim filterArray()
Dim currentFiltRange As String
Dim f As Integer
Sub sauve_filtre()
Set w = ActiveSheet
With w.AutoFilter
currentFiltRange = .Range.Address
With .Filters
ReDim filterArray(1 To .Count, 1 To 3)
For f = 1 To .Count
With .Item(f)
If .On Then
filterArray(f, 1) = .Criteria1
If .Operator = 1 Or .Operator = 2 Then
filterArray(f, 2) = .Operator
filterArray(f, 3) = .Criteria2
End If
End If
End With
Next
End With
End With
w.AutoFilterMode = False
End Sub
Sub restaure_filtre()
Dim Monfiltre As Variant
Dim Monfiltre2 As Variant
Dim col As Integer
'Set w = ActiveSheet
w.AutoFilterMode = False
For col = 1 To UBound(filterArray(), 1)
If Not IsEmpty(filterArray(col, 1)) Then
Monfiltre = filterArray(col, 1)
If filterArray(col, 2) Then
Monfiltre2 = filterArray(col, 3)
w.Range(currentFiltRange).AutoFilter field:=col, Criteria1:=Monfiltre, Operator:=filterArray(col, 2), Criteria2:=Monfiltre2
Else
w.Range(currentFiltRange).AutoFilter field:=col, Criteria1:=Monfiltre
End If
End If
Next
End Sub