+ Reply to Thread
Results 1 to 3 of 3

Lookup or index match for "contains" rather than exact match -- find/search?

  1. #1

    Lookup or index match for "contains" rather than exact match -- find/search?

    Range1:
    A1: apple
    B1: banana
    C1: carrot

    Range2:
    A2:fruit
    B2: fruit
    C2: vegetable


    A3: Granny Smith Apple



    Range 1 and Range 2 are always the same size, but much larger in
    reality.

    Here's the "formula" I want to create in A4:

    If A3 contains 'apple (the first entry in range1), then return 'Fruit'
    (the first entry in range2), if A3 contains 'banana' (the 2nd entry of
    range1) then return 'Fruit' (the 2nd entry of range2), if a3 contains
    'carrot' (the 3rd entry of range1) then return 'vegettable' (the 3rd
    entry of range2), otherwise return 'blah'

    I don't just want to write this with simple if then statements because
    Range1 and Range2 are in practice much larger. This would be easy to
    do with Match and Index if A3 exactly matched an entry in Range 1. But
    it might not. But A3 only has to CONTAIN one of the entries in Range1.

    Hope that makes sense...

    [email protected]


  2. #2
    Domenic
    Guest

    Re: Lookup or index match for "contains" rather than exact match -- find/search?

    Try...

    =IF(OR(ISNUMBER(SEARCH(A1:C1,A3))),INDEX(A2:C2,MATCH(TRUE,ISNUMBER(SEARCH
    (A1:C1,A3)),0)),"")

    ....confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

    Hope this helps!

    In article <[email protected]>,
    "[email protected]" <[email protected]> wrote:

    > Range1:
    > A1: apple
    > B1: banana
    > C1: carrot
    >
    > Range2:
    > A2:fruit
    > B2: fruit
    > C2: vegetable
    >
    >
    > A3: Granny Smith Apple
    >
    >
    >
    > Range 1 and Range 2 are always the same size, but much larger in
    > reality.
    >
    > Here's the "formula" I want to create in A4:
    >
    > If A3 contains 'apple (the first entry in range1), then return 'Fruit'
    > (the first entry in range2), if A3 contains 'banana' (the 2nd entry of
    > range1) then return 'Fruit' (the 2nd entry of range2), if a3 contains
    > 'carrot' (the 3rd entry of range1) then return 'vegettable' (the 3rd
    > entry of range2), otherwise return 'blah'
    >
    > I don't just want to write this with simple if then statements because
    > Range1 and Range2 are in practice much larger. This would be easy to
    > do with Match and Index if A3 exactly matched an entry in Range 1. But
    > it might not. But A3 only has to CONTAIN one of the entries in Range1.
    >
    > Hope that makes sense...
    >
    > [email protected]


  3. #3

    Re: Lookup or index match for "contains" rather than exact match -- find/search?

    I had never thought to use "search" as an array like this. That was
    just what I had in mind. Thank you.

    Jim


    Domenic wrote:
    > Try...
    >
    > =IF(OR(ISNUMBER(SEARCH(A1:C1,A3))),INDEX(A2:C2,MATCH(TRUE,ISNUMBER(SEARCH
    > (A1:C1,A3)),0)),"")
    >
    > ...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.
    >
    > Hope this helps!
    >
    > In article <[email protected]>,
    > "[email protected]" <[email protected]> wrote:
    >
    > > Range1:
    > > A1: apple
    > > B1: banana
    > > C1: carrot
    > >
    > > Range2:
    > > A2:fruit
    > > B2: fruit
    > > C2: vegetable
    > >
    > >
    > > A3: Granny Smith Apple
    > >
    > >
    > >
    > > Range 1 and Range 2 are always the same size, but much larger in
    > > reality.
    > >
    > > Here's the "formula" I want to create in A4:
    > >
    > > If A3 contains 'apple (the first entry in range1), then return 'Fruit'
    > > (the first entry in range2), if A3 contains 'banana' (the 2nd entry of
    > > range1) then return 'Fruit' (the 2nd entry of range2), if a3 contains
    > > 'carrot' (the 3rd entry of range1) then return 'vegettable' (the 3rd
    > > entry of range2), otherwise return 'blah'
    > >
    > > I don't just want to write this with simple if then statements because
    > > Range1 and Range2 are in practice much larger. This would be easy to
    > > do with Match and Index if A3 exactly matched an entry in Range 1. But
    > > it might not. But A3 only has to CONTAIN one of the entries in Range1.
    > >
    > > Hope that makes sense...
    > >
    > > [email protected]



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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