modify Advanced Filter code to specify criteria range on different worksheet

  • I am trying to modify some code I found in another post to filter a list and then delete certain rows based on values in a range from a different worksheet instead of the current sheet. Here is the original code from the other post:




    As I understand it the line that specifies the range containing the criteria to be used for deleting the rows is:

    Code
    .Range("K1:K2"), Unique:=False


    so I would like to change it to something like:

    Code
    .Sheets("RowDeleteCriteria").Range("A2:A100")


    Any help is much appreciated!

    Here a link to the original post: (http://www.ozgrid.com/forum/sh…ete+rows+based+criteriato)

  • Re: modify Advanced Filter code to specify criteria range on different worksheet


    Replace the .Range("K1:K2") with Sheets("RowDeleteCriteria").Range("A2:A100") - note the absence of the dot before Sheets - like this:


    Note that with the Sheets("RowDeleteCriteria").Range("A2:A100"), A2 contains the column heading (the same as Sheet1 B5), and A3:A100 contain the criteria values, none of which should be blank otherwise no data rows will remain after deleting the filtered rows. The On Error Resume Next statement in the code traps the error which occurs if that happens.

  • Re: modify Advanced Filter code to specify criteria range on different worksheet


    That did the trick. Thank you so much.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!