Find value along a row and return header name

alecambo

New Member
Joined
Apr 10, 2015
Messages
35
Office Version
  1. 2021
Platform
  1. Windows
Hello,

I need a method to find the value that's in the first column (tar2x) along its row and then return the name of the column header where it is located to a new cell (the column "Values" in this example).
For instance, the value 785 is found in the column named "5", so I would like to add that 5 to the column "Values".

tar2x1234567891011121314151617181920Values
785
779​
1140​
1253​
667​
785
907​
1254​
654​
778​
1141​
1257​
661​
893​
656​
778​
1133​
1265​
784​
896​
1013​
5
900
786​
1261​
782​
898​
1139​
1262​
653​
786​
1261​
665​
783​
898​
1022​
1254​
899​
1025​
1263​
774​
900
1134​
19
897
897
1134​
1262​
658​
773​
1013​
1135​
1258​
1263​
665​
775​
894​
1021​
1147​
1256​
662​
785​
897​
1017​
1133​
1
1013
663​
779​
1146​
1265​
1261​
657​
896​
1013
1260​
773​
1018​
1143​
655​
774​
905​
1016​
1142​
1256​
899​
1146​
8
1024
665​
775​
906​
1133​
785​
895​
1024
1136​
1264​
1146​
1265​
782​
900​
1139​
775​
1139​
656​
773​
907​
1259​
7
*I must add that the colors and the bold text have no significance, it's just to make visualization easier ;)

Then, I would like to search the returned values among a header row and return the value that's inside the cell where the value and the header name match.
For example, when I search for the value 5, I want to get the value for column named 5 (same row), in this case, a 0. For the value 19 it would be 0, for the value 1 it would be 1 and so on.
Values1234567891011121314151617181920Return
5
1​
1​
0​
0​
0
0​
1​
0​
0​
0​
0​
1​
1​
1​
1​
0​
1​
1​
0​
1​
0
19
1​
1​
1​
0​
0​
1​
0​
0​
1​
1​
1​
0​
0​
1​
1​
0​
0​
1​
0
0​
0
1
1
0​
0​
1​
0​
1​
0​
1​
0​
0​
0​
0​
0​
1​
0​
1​
1​
1​
1​
1​
1
8
1​
0​
1​
0​
0​
1​
1​
0
0​
0​
1​
1​
0​
1​
1​
0​
1​
1​
0​
0​
0
7
1​
0​
1​
1​
1​
1​
0
0​
1​
0​
0​
0​
1​
1​
1​
0​
1​
0​
0​
0​
0

Kind regards,
alecambo
 

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.
For the Values, you can use:

=MATCH(A2,B2:U2,0)

For the Return, use:

=INDEX(W2:AP2,1,MATCH(V2,W$1:AP$1,0))

Adjust to suit your actual ranges, of course.

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQ
1tar2x1234567891011121314151617181920Values1234567891011121314151617181920Return
2785779114012536677859071254654778114112576618936567781133126578489610135110000100001111011010
390078612617828981139126265378612616657838981022125489910251263774900113419111001001110011001000
4897897113412626587731013113512581263665775894102111471256662785897101711331100101010000010111111
51013663779114612651261657896101312607731018114365577490510161142125689911468101001100011011011000
610246657759061133785895102411361264114612657829001139775113965677390712597101111001000111010000
Sheet1
Cell Formulas
RangeFormula
V2:V6V2=MATCH(A2,B2:U2,0)
AQ2:AQ6AQ2=INDEX(W2:AP2,1,MATCH(V2,W$1:AP$1,0))
 
Upvote 0
Solution
Try this one.
 

Attachments

  • MrExcel3.png
    MrExcel3.png
    42.1 KB · Views: 12
Upvote 0
For the Return you could also use
Excel Formula:
=INDEX(W2:AP2,,V2)
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,265
Members
449,149
Latest member
mwdbActuary

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