Find Value in Table and Return Column Header/Row Header for Each Occurrence

jrussell19

New Member
Joined
May 16, 2013
Messages
7
Hi all,

I'll simplify the table to help, but effectively I need to return the Column Header and Row Header of each occurrence of a specific value in a table. i.e.

Value: A

A B C D E F G
1 X X X X A X X
2 X X A X X X X
3 X X X X X X X
4 X X X X X X A
5 X X X X X X X
6 X X X A X X X
7 X X X X X A X

This needs to return:
Row Header Column Header
1 E
2 C
4 G
6 D
7 F

The initial table does not have a defined amount of rows. Additional rows will be added throughout the year.

I've been pulling my hair out with match,index,offset etc but can't for the life of me work it out! Any help would be absolutely amazing!

Thanks very much.
 
Hello Peter
No, still works for me. Here it is.

Excel Workbook
ABCDEFGHIJKL
1ABCDEFGValue:A0
2aXAXXAXX1
3bXXAAAXA2
4cXXXXXXX
5dXXXXXXA3
6eXXXXXXX
7fXXXAXXX4
8gXXXXXAX5
9
10aBE
11bCDEG
12dG
13fD
14gF
15
Headers Multiple (2)


1. Does the column L formula appear to be marking the correct rows?

2. Is the column A formula producing the correct letters in A10:A14?

3. If you still cannot resolve the problem, can you upload your sample file to a file-share site (eg Dropbox) and post a link here to that file?

4. What version of Excel & what operating system are you using?
Hello Peter ,
I copied your excel cells data exactly in my excel. after pasting it changes the result.
please help me.

skill matrix (Recovered).xlsm
ABCDEFGHIJKL
1T1T2T3T4T5T6T7Value:PIC0
2AnkitXPICPICPICAXX1
3RameshXXPICPICPICXPIC2
4MinnaXXXXXXX 
5AbelXXXXXXPIC3
6KileyXXXXPICXX4
7GracielaXXXPICXXX5
8RamXXXXXPICX6
9
10AnkitT1   
11RameshT1   
12AbelT1   
13KileyT1   
14GracielaT1   
Sheet13
Cell Formulas
RangeFormula
L2:L8L2=IF(COUNTIF(B2:H2,K$1),LOOKUP(9.99E+307,L$1:L1)+1,"")
A10:A14A10=IF(ROWS(A$10:A10)>COUNT(L$2:L$8),"",LOOKUP(ROWS(A$10:A10),L$2:L$8,A$2:A$8))
B10:E14B10=IFERROR(INDEX($B$1:$H$1,SMALL(IF(INDEX($B$2:$H$8,MATCH($A10,$A$2:$A$8,0),0)=$K$1,COLUMN($B$1:$H$1)-COLUMN($B$1)+1),COLUMNS($B10:B10))),"")
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
maybe another way
Table1Table2Result
labelheader 1header 2header 3header 4header 5SearchlabelheaderValue
label 1123459label 3header 49
label 367890label 7header 29
label 510346
label 729342

Power Query:
let
    Search = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Unpivot = Table.UnpivotOtherColumns(Source, {"label"}, "header", "Value"),
    Join = Table.NestedJoin(Search,{"Search"},Unpivot,{"Value"},"Table",JoinKind.LeftOuter),
    Expand = Table.ExpandTableColumn(Join, "Table", {"label", "header", "Value"}, {"label", "header", "Value"}),
    RC = Table.RemoveColumns(Expand,{"Search"})
in
    RC
 
Upvote 0
maybe another way
Table1Table2Result
labelheader 1header 2header 3header 4header 5SearchlabelheaderValue
label 1123459label 3header 49
label 367890label 7header 29
label 510346
label 729342

Power Query:
let
    Search = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Unpivot = Table.UnpivotOtherColumns(Source, {"label"}, "header", "Value"),
    Join = Table.NestedJoin(Search,{"Search"},Unpivot,{"Value"},"Table",JoinKind.LeftOuter),
    Expand = Table.ExpandTableColumn(Join, "Table", {"label", "header", "Value"}, {"label", "header", "Value"}),
    RC = Table.RemoveColumns(Expand,{"Search"})
in
    RC
How about multiple 9 in a single row.
 
Upvote 0
Table1Table2Result
labelheader 1header 2header 3header 4header 5SearchlabelheaderValue
label 1123459label 3header 49
label 367890label 5header 29
label 519996label 5header 39
label 729342label 5header 49
label 7header 29
 
Upvote 0
How about multiple 9 in a single row.
I haven't used power query before. I know excel formulas and little macros. But I haven't used this type of code in power query before. Can you guide me how to use this code. Thank you in advance.
 
Upvote 0
I am not a teacher so in short
your source table should be an Excel Table (Ctrl+T)
create second table as Excel Table as you can see in my post (Search)
then
Get Data - From Other Sources - Blank Query
open Advanced Editor and replace code there with copied from the post
make sure the appropriate tables and table names in the code are the same
Done
Close&Load
with my code you need to use the same headers
remember that Power Query is CASE SENSITIVE

for more information:
 
Last edited:
Upvote 0
Thank you
I am not a teacher so in short
your source table should be an Excel Table (Ctrl+T)
create second table as Excel Table as you can see in my post (Search)
then
Get Data - From Other Sources - Blank Query
open Advanced Editor and replace code there with copied from the post
make sure the appropriate tables and table names in the code are the same
Done
Close&Load
with my code you need to use the same headers
remember that Power Query is CASE SENSITIVE

for more information:
Thank you for your prompt response.

But what I need in header is diffrent types of training names~ 24 names. And Student names in Label ~66 . Will it work !! Or need to make any changes
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,218
Members
453,024
Latest member
Wingit77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top