Results 1 to 3 of 3

Thread: Problem with Autofiltering on 2 Criteria in Excel

  1. #1

    Problem with Autofiltering on 2 Criteria in Excel



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    It worked fine in my test, which suggests something is interfering.

    Any chance you can post your workbook?

  3. #3
    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!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •