ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   lookup column label based on data in cell (https://www.excelbanter.com/excel-worksheet-functions/106469-lookup-column-label-based-data-cell.html)

Aaron

lookup column label based on data in cell
 
Hello

I have a table that looks something like this:
A B C D
1 0 0 0 1
2 0 0 0 0
3 0 1 0 0
4 0 1 1 0
5 0 0 0 0
6 1 0 0 0

On a separate sheet, I have the list sorted to exclude rows without a "1" in
any column. What I'd like to do, for the columns that do have a 1, is return
the column label. The column labels are reasons for events, so the result
would be for "Event" 1, "Reason" D. It doesn't matter if there's more than
one 1 in a column, only one of the reasons needs to be returned. I'd rather
not use a macro to do this, does anyone know of a way with just functions?

Thanks


Toppers

lookup column label based on data in cell
 
Try this in cell in row 2 of your filtered data and copy down (say F2):

=INDEX($A$1:$D$1,0,MATCH(1,$A2:$D2,0))

will return column heading from row 1

Is this what you require?

"Aaron" wrote:

Hello

I have a table that looks something like this:
A B C D
1 0 0 0 1
2 0 0 0 0
3 0 1 0 0
4 0 1 1 0
5 0 0 0 0
6 1 0 0 0

On a separate sheet, I have the list sorted to exclude rows without a "1" in
any column. What I'd like to do, for the columns that do have a 1, is return
the column label. The column labels are reasons for events, so the result
would be for "Event" 1, "Reason" D. It doesn't matter if there's more than
one 1 in a column, only one of the reasons needs to be returned. I'd rather
not use a macro to do this, does anyone know of a way with just functions?

Thanks



All times are GMT +1. The time now is 10:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com