Find Value in matrix Table and return column and row names

MaiyaD

New Member
Joined
Apr 22, 2019
Messages
2
Hi! Can you please help me solve in getting the row and column name given the value from a two dimensional matrix table?



Here is the table I am trying to work on:
1CDE
2Team1Team2Team 3
3Task 1Code1, Code 2Code3Code1
4Task 2Code2Code1Code 2, Code 3
5Task 3Code 3Code 2

<tbody>
</tbody>


Expected result:

Input valueTaskTeam
Code1Task1Team1
Task 1Team 3

<tbody>
</tbody>


Any help would be greatly appreciated!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Welcome to the forums. Just to clarify, shouldn't Task 2 / Team 2 also be mentioned because it has Code 1 in it?
 
Upvote 0
Probably the quickest way would be to use Power Query.

Step 1) Make the below table (copy/paste into excel), then bring it into power query. Then right click 'Code1', then click 'drill down', then click 'home', then click 'close and load to' 'only create a connection'.

Input Value
Code1

<tbody>
</tbody>

Step 2) Make the below table (copy/paste into excel), then bring it into power query.


Task No.Team 1Team 2Team 3
Task 1Code1, Code2Code3Code1
Task 2Code2Code1Code2, Code3
Task 3Code3Code 2Code3

<tbody>
</tbody>

Step 3) Go to advanced editor and paste the below. Then click 'home, then 'close and load'.

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Task No.", type text}, {"Team 1", type text}, {"Team 2", type text}, {"Team 3", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Task No."}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Columns", each Text.Contains([Value], Table1))
in
    #"Filtered Rows"

Note, you might need to alter the names of your tables/queries in order to make this work. Hope this helps...

... in the end, your spreadsheet should look something like this... and then you can just change the input value and then click refresh and everything will update. There are formulaic solutions, but i feel those would be quite complex, unless someone has an efficient idea or can provide VBA code. Good luck.

Task No.Team 1Team 2Team 3Input ValueTask No.AttributeValue
Task 1Code1, Code2Code3Code1Code1Task 1Team 1Code1, Code2
Task 2Code2Code1Code2, Code3Task 1Team 3Code1
Task 3Code3Code 2Code3Task 2Team 2Code1

<tbody>
</tbody>
 
Last edited:
Upvote 0
if you have the data in this way



Book1
ABCDE
1Team1Team2Team 3
2Task 1Code 1, Code 2Code3Code 1
3Task 2Code2Code 1Code 2, Code 3
4Task 3Code 3Code 2
5
6
7Input valueTaskTeam
8Code 1Task 1Team1
9Task 1Team 3
10Task 2Team2
Hoja1


Try with this macro

Code:
Sub Find_Value()
    Dim r As Range, ivalue As Range, b As Range
    Dim cell As String, f As Long
    
    Set r = Range("B1:E4")
    Set ivalue = Range("A8")
    
    f = 0
    Set b = r.Find(ivalue.Value, LookIn:=xlValues, lookat:=xlPart)
    If Not b Is Nothing Then
        cell = b.Address
        Do
            ivalue.Offset(f, 1).Value = Cells(b.Row, "B")
            ivalue.Offset(f, 2).Value = Cells(1, b.Column)
            f = f + 1
            Set b = r.FindNext(b)
        Loop While Not b Is Nothing And b.Address <> cell
    End If
End Sub
 
Upvote 0
A solution with formulas

A
B
C
D
E
F
G
H
I
1
Team1​
Team2​
Team 3​
Input value​
Task​
Team​
2
Task 1​
Code1, Code2​
Code3​
Code1​
Code1​
Task 1​
Team1​
3
Task 2​
Code2​
Code1​
Code2, Code3​
Task 1​
Team 3​
4
Task 3​
Code3​
Code2​
Task 2​
Team2​
5

<tbody>
</tbody>


Array formula in H2 copied down
=IFERROR(INDEX($B$2:$B$4,SMALL(IF(ISNUMBER(SEARCH($G$2,$C$2:$E$4)),ROW($C$2:$E$4)-ROW($C$2)+1),ROWS(H$2:H2))),"")
confirmed with Ctrl+Shift+Enter, not just Enter

Array formula in I2 copied down
=IF(H2="","",INDEX($C$1:$E$1,SMALL(IF(ISNUMBER(SEARCH($G$2,$C$2:$E$4)),IF($B$2:$B$4=H2,COLUMN($C$2:$E$4)-COLUMN($C$2)+1)),COUNTIF(H$2:H2,H2))))
confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Last edited:
Upvote 0
Nice one Marcelo. I was writing something similar to begin with (using ISUMBER and SEARCH), but I didn't think of doing the whole array (C2:E4), that never occurred to me (didn't know it could be done). Nice one.
 
Upvote 0
Nice one Marcelo. I was writing something similar to begin with (using ISUMBER and SEARCH), but I didn't think of doing the whole array (C2:E4), that never occurred to me (didn't know it could be done). Nice one.

Thank you. I really appreciated your comment :)

M.
 
Upvote 0
Hi Marcelo, Thank you for your feedback. It worked!

A solution with formulas

A
B
C
D
E
F
G
H
I
1
Team1​
Team2​
Team 3​
Input value​
Task​
Team​
2
Task 1​
Code1, Code2​
Code3​
Code1​
Code1​
Task 1​
Team1​
3
Task 2​
Code2​
Code1​
Code2, Code3​
Task 1​
Team 3​
4
Task 3​
Code3​
Code2​
Task 2​
Team2​
5

<tbody>
</tbody>


Array formula in H2 copied down
=IFERROR(INDEX($B$2:$B$4,SMALL(IF(ISNUMBER(SEARCH($G$2,$C$2:$E$4)),ROW($C$2:$E$4)-ROW($C$2)+1),ROWS(H$2:H2))),"")
confirmed with Ctrl+Shift+Enter, not just Enter

Array formula in I2 copied down
=IF(H2="","",INDEX($C$1:$E$1,SMALL(IF(ISNUMBER(SEARCH($G$2,$C$2:$E$4)),IF($B$2:$B$4=H2,COLUMN($C$2:$E$4)-COLUMN($C$2)+1)),COUNTIF(H$2:H2,H2))))
confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0
Hi Marcelo.

Thank you so much for this post.
I was struggling with this situation and your formulas helped me a lot.
But, somehow, they don't work with my matrix table.
My table consists of alphanumeric values and these formulas only work (sort of) if I round the value to find to 2 decimals.

Are you willing to help me?

Best regards.

H.
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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