+ Reply to Thread
Results 1 to 9 of 9

Filter using "not equal to" criteria using array

  1. #1
    Registered User
    Join Date
    04-09-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Filter using "not equal to" criteria using array

    Hello. My current filter is this:
    Please Login or Register  to view this content.
    The "StaffArray" contains 29 entries.
    What I want is to filter and show whatever is NOT in the staff array. I tried all sorts of syntax like:
    Please Login or Register  to view this content.
    But all of them returned errors.
    From doing some search, people were mentioning something along the lines of "use a formula column to determine whether to include or exclude the values". Maybe they mean this: create some kind of formula that uses the "StaffArray" and searches the field/column in question, and then creates another array containing the values that are not the same as in "StaffArray"... Am I making any sense? If yes, then how do I do this?

    I'm only looking for a solution; i.e. it doesn't have to be optimized to run fast.
    Last edited by AlaaAlii; 05-10-2012 at 09:05 AM.

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,599

    Re: Filter using "not equal to" criteria using array

    PL try this.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-09-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Filter using "not equal to" criteria using array

    No, you misunderstood. I'm filtering on two columns: 12 and 9. The 12 one is just OPEN, PREAPPROVED and WORKINPROGRESS, I have no issues with that. But the second column/field, field 9, is being filtered using an array called "StaffArray". What I want is to filter this field, field 9, and criteria would be NOT equal to StaffArray.

    I'll edit the first post to remove that first filter since it's irrelevant.

  4. #4
    Registered User
    Join Date
    04-09-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Filter using "not equal to" criteria using array

    Anyone?
    Well, I gave in, and I thought I'd just do something like what kvsrinivasamurthy said.
    I did...
    Please Login or Register  to view this content.
    ...up until Name29. But it didn't work =(, it gives an AutoFilter Method of Range Class Failed error.

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Filter using "not equal to" criteria using array

    you can't do that with an autofilter. you'd need to use an advanced filter instead
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Registered User
    Join Date
    04-09-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Filter using "not equal to" criteria using array

    How do I do that? How do I use it to show values that are NOT equal to certain values?

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Filter using "not equal to" criteria using array

    you need a criteria range of two cells. the top one is blank and then use a formula like this in the second cell:
    =isna(match(I2,data_range,0))
    where I2 is the first cell of data to be tested and data_range is a range containing the values to exclude.

  8. #8
    Registered User
    Join Date
    04-09-2012
    Location
    Saudi Arabia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Filter using "not equal to" criteria using array

    Ok, I'm stuck. I understand the basics of how advanced filters work. Your formula returns a TRUE (if the cell being tested does not equal to the range of values to exclude), else it returns FALSE. If I run the advanced filter on this, it's just looking for values with TRUE or FALSE in them. Also, you said to leave the top cell blank (in the criteria range); wouldn't that essentially make the advanced filter show everything?

    EDIT: well I've got an idea. Using your formula: if it returns true, copy the value of the data being tested into an array. Then move to the next cell, and if it's true, copy the data to the array as well. So, in the end, I'll have an array that I can use using the normal autofilter, get it?
    If this will work, I need help as well =/, because I'm completely new to VBA.
    Last edited by AlaaAlii; 05-11-2012 at 07:10 AM.

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Filter using "not equal to" criteria using array

    Quote Originally Posted by AlaaAlii View Post
    Ok, I'm stuck. I understand the basics of how advanced filters work. Your formula returns a TRUE (if the cell being tested does not equal to the range of values to exclude), else it returns FALSE. If I run the advanced filter on this, it's just looking for values with TRUE or FALSE in them. Also, you said to leave the top cell blank (in the criteria range); wouldn't that essentially make the advanced filter show everything?
    your criteria range is two cells only. the top one is blank and the bottom one has that formula in it. using those as the criteria the filter will evaluate for each row and hide any where the result is false

    EDIT: well I've got an idea. Using your formula: if it returns true, copy the value of the data being tested into an array. Then move to the next cell, and if it's true, copy the data to the array as well. So, in the end, I'll have an array that I can use using the normal autofilter, get it?
    If this will work, I need help as well =/, because I'm completely new to VBA.
    yes you could also use an additional formula column and simply autofilter for true in addition to your other column filter.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1