Sub FilterUC()
Dim ActiveColumn As Integer
Dim MyRange As Range
Dim col1 As Variant
Dim Crit1 As Variant
Dim AFRange As Range
Dim col2, col3, col4, col5, col6 As String
Dim Crit2, Crit3, Crit4, Crit5, Crit6 As String
ActiveSheet.AutoFilterMode = False
Set MyRange = ActiveCell.CurrentRegion
If MyRange.Cells.Count = 1 Then
MsgBox "Select a cell within the range to be filtered"
Exit Sub
End If
ActiveColumn = ActiveCell.Column - MyRange.Cells(1, 1).Column + 1
If CheckBox16.Value = True Then
col1 = TextBox34
'If col1 = False Then Exit Sub
If col1 > MyRange.Columns.Count Then
MsgBox " No Collone" & MyRange.Address(False, False)
Exit Sub
End If
Crit1 = TextBox35
If Crit1 = "" Then
MyRange.AutoFilter Field:=col1
'Criteria1:=Crit1
On Error Resume Next
Set AFRange = MyRange.Offset(1, 0).Resize(MyRange.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not AFRange Is Nothing Then
If CheckBox17.Value = True Then
'MsgBox("il ya " & AFRange.Cells.Count / AFRange.Columns.Count & " valeurs", vbYesNo, "Continue pour choisir une autre collone") = vbYes Then
col2 = TextBox36
If col2 = False Then Exit Sub
If col2 > MyRange.Columns.Count Then
MsgBox "No Collone" & MyRange.Address(False, False)
ActiveSheet.AutoFilterMode = False
Exit Sub
End If
Crit2 = TextBox37
'If Crit2 = "" Then Exit Sub
MyRange.AutoFilter Field:=col2, Criteria1:=Crit2
On Error Resume Next
Set AFRange = MyRange.Offset(1, 0).Resize(MyRange.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End If
End If
End If
End If
End Sub