+ Reply to Thread
Results 1 to 12 of 12

Lookup & Display Value in Topmost Row

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    37

    Lookup & Display Value in Topmost Row

    Hi all,

    I'm trying to do a Lookup function but can't really able to work out. Appreciate if anyone could help me out.
    Thanks in advance!

    My data is made up of : Column A is Animal Category (eg. Cat, Dog, Horse, Deer) & Column B is Insect Category (Moth, Beetle, Mosquito, Ladybug).

    In column C, I would have the subject (eg. Dog / Beetle).
    I want to do a lookup formula in D1 so that whenever I put in the subject in column C, it would identify what category it belongs to by 'searching' the data in columns A & B. For example, by entering "Dog" in C1, D1 will automatically search for "Dog" in data range A:B & display "Animal".
    Attached Files Attached Files
    Last edited by donkeybusiness; 06-08-2013 at 11:06 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-04-2009
    Location
    Texas
    MS-Off Ver
    Excel 2016
    Posts
    665

    Re: Lookup & Display Value in Topmost Row

    =if(countif($A$1:$A$30,$C1)>0,"Animal",if(countif($B$1:$B$30,$C1)>0,"Insect",""))

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Lookup & Display Value in Topmost Row

    HI donkeybusiness,

    try using below formula:-

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Registered User
    Join Date
    08-01-2012
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Lookup & Display Value in Topmost Row

    That was quick! Crimedog's formula works.
    If I have a lot of categories, I'll have a lot of IF & COUNTIFS then?

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup & Display Value in Topmost Row

    This formula might work better with a lot of catagories (assuming that the value will be unique to a specific catagory

    =INDEX($A$1:$B$1,SUMPRODUCT(($A$2:$B$5=C2)*COLUMN($A$2:$B$5)))
    A1:B1 are your catagory headers, A2:B5 is your data range
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    08-01-2012
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Lookup & Display Value in Topmost Row

    Great! Many thanks!

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup & Display Value in Topmost Row

    isnt that an array formula? this one certainly is

    =INDEX(A1:G1,MAX((A1:G6=J2)*COLUMN(A1:G6)-MIN(COLUMN(A1:G6))+1)) where j2 has say tiger in it
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup & Display Value in Topmost Row

    The one I suggested is not an array function.

  9. #9
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Lookup & Display Value in Topmost Row

    hmm it returns value when i tried it and had to array enter it to work
    now that is strange it works in one workbook but not another
    it seems to not work in one i'd opened from a forum link but ok in one i open on my pc
    Last edited by martindwilson; 06-07-2013 at 10:57 AM.

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup & Display Value in Topmost Row

    That is odd. Computers are funny things.

  11. #11
    Registered User
    Join Date
    08-01-2012
    Location
    KL
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Lookup & Display Value in Topmost Row

    What if in the event that the animal is not in the category, it'll tell me "Not Available" ?

  12. #12
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Lookup & Display Value in Topmost Row

    =IF(SUMPRODUCT(--($A$2:$G$7=J2))=0,"Not Available",INDEX($A$1:$G$1,SUMPRODUCT(($A$2:$G$7=J2)*COLUMN($A$2:$G$7)))) where the item to be looked up in is J2
    Good?

+ 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