Need a formula to return header if cell is not blank and concatenate the header names separated by comma

bb19august

New Member
Joined
Feb 1, 2019
Messages
18
CarBusTrainResult
11Car, Bus
22Bus, Train
1NoCar, Train
73Car, Bus
10YesCar, Train

<tbody>
</tbody>

Request your help to have a formula in excel to get a result as shown above. Cells could have numbers or blanks or text. if there is any number/text in any cell(s)the header(s) has to copied and concatenated and separated by comma.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
In D2 copied down
=TRIM(SUBSTITUTE(IF(A2<>"",A$1,",")&IF(B2<>"",", "& B$1,"")&IF(C2<>"",", "&C$1," "),",,",""))

Excel 2016 (Windows) 32 bit
A
B
C
D
E
1
CarBusTrainResult
2
1​
1​
Car, Bus=TRIM(SUBSTITUTE(IF(A2<>"",A$1,",")&IF(B2<>"",", "& B$1,"")&IF(C2<>"",", "&C$1," "),",,",""))
3
2​
2​
Bus, Train
4
1​
NoCar, Train
5
7​
3​
Car, Bus
6
10​
YesCar, Train
7
YesTrain
Sheet: Sheet2
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,432
Members
448,961
Latest member
nzskater

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