Reputation: 1
I have command buttons to auto filter, the first and second work, the third doesn't, I want to filter by two criteria and two columns. Any ideas?
Private Sub CommandButton6_Click()
Worksheets("Sheet1").Range("K4 : K1900").AutoFilter _
Field:=1, _
Criteria1:="No", _
VisibleDropDown:=False
End Sub
Private Sub CommandButton7_Click()
Cells.AutoFilter
End Sub
Private Sub CommandButton8_Click()
Worksheets ("Sheet1")
.Range("K4:K1900").AutoFilter
.Range("C4:C1900").AutoFilter
Field:=1,
Criteria1:="No", _
Criteria1:="City",_
VisibleDropDown:=False
End Sub
Upvotes: 0
Views: 110
Reputation: 9976
You may try it like this...
Private Sub CommandButton8_Click()
With Worksheets("Sheet1").Range("C4:K1900")
.AutoFilter field:=9, Criteria1:="No" 'field:=9 means the 9th column in the filtered range
.AutoFilter field:=1, Criteria1:="City" 'field:=1 means the 1st column in the filtered range
End With
End Sub
Upvotes: 1