Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Excel: How to return a column header matching two cell values?

N1 N2 N3
A1 Matt Tom Bob
A2 Tom Bob Matt

I would like to have a function that returns the Column header (N1, N2, N3, N4) based on two cell values. For example, if I have "A1" and "Tom", I want the function to return N2. I have tried the function:
=INDEX($B$1:$D$1, SUMPRODUCT(MAX(($B$2:$D$3=G2)*(COLUMN($B$2:$D$3))))-COLUMN($B$1)+1)

(G2 is the lookup value cell)

This formula works great until you have duplicate values like the table above.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there another formula that could work better for this?

>Solution :

use a nested INDEX/MATCH:

=INDEX($B$1:$D$1,MATCH(G2,INDEX(B:D,MATCH(G1,A:A,0),0),0))

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading