+ Reply to Thread
Results 1 to 7 of 7

Return Header based on a lookup of row and value within row

  1. #1
    Registered User
    Join Date
    10-17-2009
    Location
    Palo Alto
    MS-Off Ver
    Excel 2003
    Posts
    4

    Return Header based on a lookup of row and value within row

    Hi all,

    I have been a lurker of this forum for a few years and always managed to find the answer to my questions by perusing old posts. After hours of trying different index/match/sumif variations, then searching for an answer, I decided it was time to finally post a question.

    I am trying to return the column heading (or column number) based on the intersection of a particular row and a particular value within that row. I've tried to illustrate the problem with a table below, obviously not the model I am working with, but should give you the idea.

    I need to lookup "Row 3", the value 10, and return "Header 5", etc.

    While the row value and header values are unique, the values that are populated in the table may repeat, as illustrated below.

    Any ideas??

    Header 1 Header 2 Header 3 Header 4 Header 5 Header 6
    Row 1 1 2 3 4 5 6
    Row 2 0 0 5 6 7 8
    Row 3 0 0 0 9 10 11
    Row 4 0 1 2 3 4 5
    Row 5 1 2 3 4 0 0
    Row 6 0 0 0 6 7 8
    Last edited by lelaina; 03-03-2011 at 02:56 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Return Header based on a lookup of row and value within row

    Assuming your data is in A1:G7, try:

    =INDEX($B$1:$G$1,MATCH(10,INDEX($B$2:$G$7,MATCH("Row 3",$A$2:$A$7,0),0),0))

    adjust as necessary.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: Return Header based on a lookup of row and value within row

    See attached for example.

    The main issue would be if there were any repeated values within the same row, as you would only be able to bring back the first matching header. So for instance, putting in a value of 0 brings back Header 1, but 0 also appears in cols for Header 2 and 3 for Row 3.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    10-17-2009
    Location
    Palo Alto
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Return Header based on a lookup of row and value within row

    Thank you for such prompt responses!

    I started with NBVC's solution (which was very similar to what I was trying earlier) but it isn't working.

    NBVC - did you intend for the 2nd Index to have a column num 0?

    I'll try brokenbiscuits next...

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Return Header based on a lookup of row and value within row

    Yes the 0 is meant to be there. It forces the INDEX function to return the range.

    See attached.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    10-17-2009
    Location
    Palo Alto
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Return Header based on a lookup of row and value within row

    Thank you! I was actually finally able to get both ways to work... saved me several hours of angst this afternoon!

  7. #7
    Registered User
    Join Date
    07-23-2014
    Location
    portland, or
    MS-Off Ver
    microsoft 2010
    Posts
    6

    Re: Return Header based on a lookup of row and value within row

    I need to do the same thing, but as one of you mentioned this only returns the first header matching the value. Is there any other way to do this so I can return all of the matching headers?

    Holly

+ 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