Martin--
Here's the code for the command button:
CODE
Private Sub cmdApply_Click()
Dim strName1 As String, strName2 As String
Dim strNumber As String, intOperator As Integer
strName1 = Me.txtCriteria1
strName2 = Me.txtCriteria2
strNumber = Me.txtNumberCriteria
intOperator = xlAnd
If Me.optOr = True Then intOperator = xlOr
With Me
.txtCriteria1 = ""
.txtCriteria2 = ""
.txtNumberCriteria = ""
.Hide
End With
If strName1 <> "" Then
If strName2 <> "" Then
Selection.AutoFilter Field:=6, Criteria1:="=*" & strName1 _
& "*", Operator:=intOperator, Criteria2:="=*" & strName2 _
& "*"
Else
Selection.AutoFilter Field:=6, Criteria1:="=*" & strName1 & "*", Operator:=xlAnd
End If
Else
Selection.AutoFilter Field:=6
End If
If strNumber <> "" Then
Selection.AutoFilter Field:=3, Criteria1:="=*" & strNumber & "*", Operator:=xlAnd
Else
Selection.AutoFilter Field:=3
End If
End Sub
I've moved the .Hide command up further in the code to try to get the focus on the sheet; it used to be at the end of this code.
Thanks for looking at this.
--Eric
Edited by: Harfleur on Wed Feb 14 15:14:07 EST 2007.