Search code examples
arraysexcelexcel-2007worksheet-functionarray-formulas

Trying to select a distinct set of values but exclude some


I have an Excel column that contains names of fruits and from this list I want to only extract the unique set of values into another Worksheet. However to complicate it there are some known values I do not wish to be included. Example:

Column H
    Orange
    Apple
    Melon
    Orange
    Lemon
    Lemon
    Lemon
    Raspberry
    Kiwi             - I want this to be excluded.

From the above list I want to exclude Kiwi so my final list would be:

Column C
    Orange
    Apple
    Melon
    Lemon
    Raspberry

I am using Excel 2007, VBA can be used if necessary but preference is normal/array formula. I have found some array formula that could give me a distinct list but not sure how to extend it to exclude Kiwi:

=IFERROR(INDEX('Fruit'!$H$2:$H$100, MATCH(0, COUNTIF($C$1:C1, 'Fruit'!$H$2:$H$100), 0)),"")

Can anyone help?


Solution

  • Please try:

    {=IFERROR(INDEX(Fruit!$H$2:$H$100, MATCH(0,IF(Fruit!$H$2:$H$100<>"Kiwi",COUNTIF($C$1:C1, Fruit!$H$2:$H$100)), 0)),"")}