Retrieving Column Header values in a grid

mattyblueice

Board Regular
Joined
Jul 24, 2014
Messages
87
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?

[TABLE="width: 900"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Client[/TD]
[TD]Codes[/TD]
[TD]B12[/TD]
[TD]B14[/TD]
[TD]B36[/TD]
[TD]B45[/TD]
[TD]B68[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Smith[/TD]
[TD]B12, B36, B45[/TD]
[TD]X[/TD]
[TD][/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Jones[/TD]
[TD]B14, B36, B45[/TD]
[TD][/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Paul[/TD]
[TD]B12, B14, B36, B45, B68[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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 [TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"] =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 [TABLE="width: 95"]
<tbody>[TR]
[TD="width: 95"] =CONCATENATE(J2&","&" ",K2&"," &" ",L2) I just did one client but you should get the idea.

[TABLE="width: 863"]
<colgroup><col span="8"><col><col span="4"></colgroup><tbody>[TR]
[TD]Client[/TD]
[TD]B12[/TD]
[TD]B14[/TD]
[TD]B36[/TD]
[TD]B45[/TD]
[TD]B68[/TD]
[TD][/TD]
[TD]Client[/TD]
[TD]Concat Codes[/TD]
[TD]Codes[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Smith[/TD]
[TD]x[/TD]
[TD][/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD]Smith[/TD]
[TD]B12, B36, B45[/TD]
[TD]B12[/TD]
[TD]B36[/TD]
[TD]B45[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Jones[/TD]
[TD][/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD]Jones[/TD]
[TD][/TD]
[TD]B14[/TD]
[TD]B36[/TD]
[TD]B45[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Paul[/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD][/TD]
[TD]Paul[/TD]
[TD][/TD]
[TD]B12[/TD]
[TD]B14[/TD]
[TD]B36[/TD]
[TD]B45[/TD]
[/TR]
</tbody>[/TABLE]



[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,316
Members
452,634
Latest member
cpostell

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