Problem with Autofiltering on 2 Criteria in Excel

katkth7533

New member
Joined
Jul 29, 2014
Messages
17
Reaction score
0
Points
0
I am having trouble with a macro that I am using to autofilter a table. I am looking to have the macro return all entries in cells P6 thru P625 that are either "Development" or "MS" and to display these. I used the code below (attached to a ActiveX command button) and it is not working. The worksheet has a password so I started with unprotecting the sheet (then reprotecting after running the filter). Any ideas where I went wrong?

Thank you

Code:
Private Sub CommandButton1_Click()
    ActiveSheet.Unprotect Password:="xxxx"
    Range("P6:P625").AutoFilter Field:=1, Criteria1:="Development", Operator:=xlOr, Criteria2:="MS"
    ActiveSheet.Protect Password:="xxxx"
    
End Sub
 
It worked fine in my test, which suggests something is interfering.

Any chance you can post your workbook?
 
I just re-looked at this after you replied and did see something wrong. It is now working. Thanks so much for the reply and for prompting me to look this over. Have a good day!
 
Back
Top