+ Reply to Thread
Results 1 to 8 of 8

opposite of vlookup function?

  1. #1
    Registered User
    Join Date
    05-24-2004
    Posts
    16

    opposite of vlookup function?

    i need a formula that is kind of opposite of vlookup.

    in a table of data, i need to locate a specific data and return the column heading of that data.
    for example, let's say i have a table:
    fruit veggies dairy
    apple cucumber cheese
    banana squash milk

    if a1 = "apple"
    i need to find a1 in the table and return "fruit"

    is this possible?

    any help would be appreciated!

  2. #2
    Forum Contributor
    Join Date
    06-21-2004
    Posts
    106
    Do a help search on HLOOKUP.

  3. #3
    Dave F
    Guest

    RE: opposite of vlookup function?

    HLOOKUP may work?

    "ayl322" wrote:

    >
    > i need a formula that is kind of opposite of vlookup.
    >
    > in a table of data, i need to locate a specific data and return the
    > column heading of that data.
    > for example, let's say i have a table:
    > fruit veggies dairy
    > apple cucumber cheese
    > banana squash milk
    >
    > if a1 = "apple"
    > i need to find a1 in the table and return "fruit"
    >
    > is this possible?
    >
    > any help would be appreciated!
    >
    >
    > --
    > ayl322
    > ------------------------------------------------------------------------
    > ayl322's Profile: http://www.excelforum.com/member.php...fo&userid=9846
    > View this thread: http://www.excelforum.com/showthread...hreadid=570867
    >
    >


  4. #4

    Re: opposite of vlookup function?

    Hlookup doesn't do what he wants.

    He wants to search the table data for a particular value, and then
    return the header.

    For a single column:

    =IF(NOT(ISNA(MATCH(A1,B3:B99))),B2,0)

    where A1 is the test value, B3:B99 is the lookup column and B2 is the
    header.

    Now you just have to replace the 0 in the false portion with similar
    lookups for the other columns in your table.

    =IF(NOT(ISNA(MATCH(A1,B3:B99))),B2,IF(NOT(ISNA(MATCH(A1,C3:C99))),c2,0)
    )

    Etc.


    pikapika13 wrote:
    > Do a help search on HLOOKUP.
    >
    >
    > --
    > pikapika13
    > ------------------------------------------------------------------------
    > pikapika13's Profile: http://www.excelforum.com/member.php...o&userid=10892
    > View this thread: http://www.excelforum.com/showthread...hreadid=570867



  5. #5
    Registered User
    Join Date
    05-24-2004
    Posts
    16
    but HLOOKUP would search for the matching data in the column headings only, right?
    i need it to search the body of the table for the data and return the column heading?

  6. #6
    Bernie Deitrick
    Guest

    Re: opposite of vlookup function?

    You need an extra column of helper cells.

    With your example table in A1:C3, enter

    D1 Apple
    D2 =IF(ISERROR(MATCH($D$1,A2:C2,FALSE)),0,MATCH($D$1,A2:C2,FALSE))
    copy D2 to D3

    Then use

    =INDEX(1:1,MAX(D2:D3))

    to return 'Fruit' - but note that, botanically, both cucumbers and aquash are fruit ;-)


    HTH,
    Bernie
    MS Excel MVP


    "ayl322" <[email protected]> wrote in message
    news:[email protected]...
    >
    > i need a formula that is kind of opposite of vlookup.
    >
    > in a table of data, i need to locate a specific data and return the
    > column heading of that data.
    > for example, let's say i have a table:
    > fruit veggies dairy
    > apple cucumber cheese
    > banana squash milk
    >
    > if a1 = "apple"
    > i need to find a1 in the table and return "fruit"
    >
    > is this possible?
    >
    > any help would be appreciated!
    >
    >
    > --
    > ayl322
    > ------------------------------------------------------------------------
    > ayl322's Profile: http://www.excelforum.com/member.php...fo&userid=9846
    > View this thread: http://www.excelforum.com/showthread...hreadid=570867
    >




  7. #7
    Registered User
    Join Date
    05-24-2004
    Posts
    16
    thank you~
    i think that will work.

    lol..are cucumbers and squash really fruit?
    i was just using that as an example so it doesn't matter, but i guess you learn something new everyday!

  8. #8
    Bernie Deitrick
    Guest

    Re: opposite of vlookup function?

    > lol..are cucumbers and squash really fruit?
    > i was just using that as an example so it doesn't matter, but i guess
    > you learn something new everyday!


    Botanically, if not practically. Scientifically, a fruit is a body that contains seeds, usually (if
    not always) produced where a flower had been. Tomatoes, beans, peas, watermelon, peppers, eggplant,
    etc. are all fruit. Vegetables are things where you use the leaves, stems, or roots. Carrots,
    swisschard, celery, beets, spinach, rhubarb, etc. are vegetables.

    The practical definition is more about use - if they are used as dessert, then they are fruits - or
    something along those lines....

    Bernie
    MS Excel MVP



+ 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