Retrieving Column Header values in a grid

mattyblueice

Board Regular
Joined
Jul 24, 2014
Messages
85
Office Version
  1. 365
Platform
  1. MacOS
I have a large client product ID grid I am working with where I am trying to develop a formula that will pick up the column header values (product ID) if an X is present in the cell. The formula is in the Codes column, below is a sample of what I am working with but there are many product codes and clients.

I have researching formulas IF, MATCH and INDEX, but I am stuck about how to get this to work? Can anyone offer any suggestions please?

ABCDEFGH
1ClientCodesB12B14B36B45B68
2SmithB12, B36, B45XXX
3JonesB14, B36, B45XXX
4PaulB12, B14, B36, B45, B68XXXXX

<tbody>
</tbody>
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
In excel 2016, I might do something like
=TEXTJOIN(",",TRUE,IF($E4:$I4="X",$E$3:$I$3,"")) with CTRL+SHIFT+ENTER
 
Upvote 0
Hi Momentman - just trying to understand the ranges and how the formula would work, for example the formula would reside in the C2 and then copied down. I think you meant:

=TEXTJOIN(",",TRUE,IF($D2:$H2="X",$D$1:$H$1,""))

Does the first range D2:H2 search the row for an "X" and if True returns the value in the range D1:H1?
 
Upvote 0
Hi Momentman - just trying to understand the ranges and how the formula would work, for example the formula would reside in the C2 and then copied down. I think you meant:

=TEXTJOIN(",",TRUE,IF($D2:$H2="X",$D$1:$H$1,""))

Does the first range D2:H2 search the row for an "X" and if True returns the value in the range D1:H1?
Exactly - sorry about the range change
 
Upvote 0
Good Morning! Thanks - sorry for the long reply, I left work early. I put that in and did the Ctrl-Shift-enter and I get a #NAME ? error. Did I miss a step?
 
Upvote 0
That function wouldn't work over there, expectedly :)
 
Upvote 0
Can you use something like this. I first used
=IFERROR(INDEX($B$1:$F$1,SMALL(IF($A$2:$A$4=$H2,IF($B$2:$F$4="x",COLUMN($B$1:$F$1)-COLUMN($B$1)+1)),COLUMNS($J$2:J2)))," ") to find all the codes for the client. Then I used
=CONCATENATE(J2&","&" ",K2&"," &" ",L2) I just did one client but you should get the idea.

ClientB12B14B36B45B68ClientConcat CodesCodes
SmithxxxSmithB12, B36, B45B12B36B45
JonesxxxJonesB14B36B45
PaulxxxxxPaulB12B14B36B45

<colgroup><col span="8"><col><col span="4"></colgroup><tbody>
</tbody>




<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,213,565
Messages
6,114,338
Members
448,570
Latest member
rik81h

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