Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Display Column First Row Header when Matched

Posted on 2014-07-18
5
Medium Priority
?
210 Views
Last Modified: 2014-08-04
Hello Experts,
 
I need an Excel 2010 formula that will display the first header row when a match is found within an array based on a value:
 
Value        Result from first row
Oakland = City
Bob = Name

ID   Name  City
1      Joe      Houston
2      Bob     New York
3      Jill        Oakland
0
Comment
Question by:ShadowIT
  • 3
  • 2
5 Comments
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40205713
I'm going to re-state your question; please confirm that this is correct.

A table exists with data.  A user enters an arbitrary value.  A formula is desired that will identify the type of information as listed in a header row of the table.

For example, if a table contains three columns of data, with the header row containing:
A1:  "ID"
B1: "Name"
C1: "City"

with values below being:
A2: 1
B2: "Joe"
C2: "Houston"
A3: 2
B3: "Bob"
C3: "New York"
A4: 3
B4: "Jill"
C4: "Oakland"

and the user enters the value "Oakland" in a cell, the formula will return the value "City"
Likewise, if the user enters the value "Bob", the formula will return the value "Name"

1) What if a value occurs in more than one column?  For example, "Austin" could be a person's name or the name of a city.
2) What do you want to see if there is no match?


-Glenn
0
 

Author Comment

by:ShadowIT
ID: 40205742
Yes, that's right

1) What if a value occurs in more than one column?  For example, "Austin" could be a person's name or the name of a city.

Just the first it encounters it fine

 2) What do you want to see if there is no match?

N/A..zero...no match found...doesn't really matter to me
0
 

Author Comment

by:ShadowIT
ID: 40205904
this is close but only works if I specify a specific row and I need this to work for an array:

=INDEX($A$1:$E$1,1, MATCH(1,$A2:$E2,0))
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40206519
Shadow,

I'm close to a solution, but am trying to avoid either nested IF statements (an approach seen here in EE) or a helper row.  Both cases work (I have a workbook with both types), but am trying to see if I can use an array function instead.

-Glenn
0
 
LVL 27

Accepted Solution

by:
Glenn Ray earned 2000 total points
ID: 40230153
Shadow,

Sorry for the long delay in getting a solution to you, but I did figure it out.  Assuming the value to search for is in G2, the formula to return the header row lable (field name) would be:
=IFERROR(INDEX($A$1:$E$1,1,SUMPRODUCT(($A$1:$E$20=$G$2)*(COLUMN($A$1:$E$20)))/COUNTIF($A$1:$E$20,$G$2)),"Not Found")

This is only searching down to row 20; you'd want to change that value accordingly.  Example workbook attached.

-Glenn
EE-IdentifyColumn.xlsx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question