Thread: [Solved] filter sheet
View Single Post
 
Old 01-10-2015, 08:27 AM
whatsup whatsup is offline Windows 7 64bit Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Hi

In order to filter on 2 criterias you will have to submit Criteria1 and Criteria2. The part for filtering has to look like this:
Code:
.
.
.
With Sheet1.Range("A3:C" & EOR)
        
        If ComboBox1.Text <> Empty Then
            .AutoFilter Field:=1, Criteria1:="=" & ComboBox1.Text
        Else
            Exit Sub
        End If
        If TextBox1.Text <> "" Then
            If TextBox2.Text <> "" Then
                .AutoFilter Field:=2, Criteria1:=">=" & TextBox1.Value, Criteria2:="<=" & TextBox2.Value
            Else
                .AutoFilter Field:=2, Criteria1:=">=" & TextBox1.Value
            End If
        Else
            If TextBox2.Text <> "" Then
                .AutoFilter Field:=2, Criteria1:=">=" & TextBox2.Value
            End If
        End If
        
        'If TextBox3.Text <> Empty Then .AutoFilter Field:=3, Criteria1:=">=" & TextBox3.Value
        'If TextBox4.Text <> Empty Then .AutoFilter Field:=3, Criteria2:="<=" & TextBox4.Value
    End With
End Sub
The same structure you will need for TextBox3 and 4

Cheers
Reply With Quote