It worked ok for me when I left the textbox empty.
If you want to use selects, you can get rid of the "With activesheet":
Option Explicit
Private Sub btnSearch_Click()
Worksheets("sheet1").AutoFilterMode = False
Worksheets("sheet1").Range("a1").Select
Selection.AutoFilter Field:=1, Criteria1:=Me.txtChaseJobNo.Value
Selection.AutoFilter Field:=2, Criteria1:=Me.txtChaseBranch.Value
Selection.AutoFilter Field:=3, Criteria1:=Me.txtChaseRef.Value
Selection.AutoFilter Field:=4, Criteria1:=Me.txtChaseName.Value
End Sub
If you filtered manually, do you see any results. The autofilter is
cumulative--each subsequent filter will reduce the number of visible rows (or
leave the number of visible cells the same depending on your data).
Ohhhh. I think I get it. You want to ignore that textbox if it's left blank
and just filter on the remaining?????
Option Explicit
Private Sub btnSearch_Click()
Worksheets("sheet1").AutoFilterMode = False
Worksheets("sheet1").Range("a:H").Select
If Trim(Me.txtChaseJobNo.Value) <> "" Then
Selection.AutoFilter Field:=1, Criteria1:=Me.txtChaseJobNo.Value
End If
If Trim(Me.txtChaseBranch.Value) <> "" Then
Selection.AutoFilter Field:=2, Criteria1:=Me.txtChaseBranch.Value
End If
If Trim(Me.txtChaseRef.Value) <> "" Then
Selection.AutoFilter Field:=3, Criteria1:=Me.txtChaseRef.Value
End If
If Trim(Me.txtChaseName.Value) <> "" Then
Selection.AutoFilter Field:=4, Criteria1:=Me.txtChaseName.Value
End If
End Sub
I really hate letting excel guess at the range. This time I changed the range
to be filtered to columns A:H. Adjust it as required.
I've always found that excel doesn't guess the range that I want if I have a
blank row or blank column in the middle of my "real" range.