Return the value of a header row if cell contains data

DctheDC

New Member
Joined
Jun 7, 2016
Messages
37
Hi all

I have a list of names in a column A and a list of categories Cols B-F

Each person can be tagged to several categories with the value of either 0 1 2 3 or 4

I am after a way to create a separate summary sheet that will tell me the person’s name in one cell (which I can do with =Sheet1!A2 ) and a string of text delimited by commas showing all the categories they have been tagged too regardless of the value used.

Example Table

ABCDEF
12345
Bob032
Peter340
Frank4203

<tbody>
</tbody>

Result:

AB
Bob2,3,5
Peter3,4,5
Frank1,2,3,5

<tbody>
</tbody>


My full list of data has over 150 people and 160 different categories

Any Ideas?

Thanks
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
In K2 control+shift+enter, not just enter, and copy down:

=TEXTJOIN(",",TRUE,IF(ISNUMBER(B2:F2),$B$1:$F$1,""))
 
Upvote 0
using VBA, puts data on second sheet

Code:
Sub t()
Dim c As Range, i As Long, lc As Long, ssh As Worksheet, sh As Worksheet, cat As String
Set ssh = ActiveSheet
Set sh = Sheets(2) 'Edit sheet name
    With ssh
        For Each c In .Range("A2", .Cells(Rows.Count, 1).End(xlUp))
            If c <> "" Then
                lc = .Cells(c.Row, Columns.Count).End(xlToLeft).Column
                    For i = 2 To lc
                        If .Cells(c.Row, i) <> "" Then
                            If cat = "" Then
                                cat = .Cells(1, i).Value
                            Else
                                cat = cat & ", " & .Cells(1, i).Value
                            End If
                        End If
                    Next
                sh.Cells(Rows.Count, 1).End(xlUp)(2) = c.Value
                sh.Cells(Rows.Count, 1).End(xlUp).Offset(, 1) = cat
                cat = ""
            End If
        Next
    End With
End Sub
 
Upvote 0
Thanks a lot for your response Aladin, is there a way to have the Summary on another sheet? I tried prefixing the formula with =Sheet1! but it would not work

Thanks JLGWhiz, I liked the VBA option too :)

Cheers
 
Upvote 0
The names will be in cell A1, with the text string in cell B1, but I can pull them in using a simple =Sheet1!A2 formula. They need to be in separate cells as hopefully I will be 'Counting' the digits from the cell B1
 
Upvote 0
The names will be in cell A1, with the text string in cell B1, but I can pull them in using a simple =Sheet1!A2 formula. They need to be in separate cells as hopefully I will be 'Counting' the digits from the cell B1

If this is in Sheet1:


Book1
ABCDEF
112345
2Bob032
3Peter340
4Frank4203
Sheet1


do we have in Summary something like this:


Book1
A
1
2Bob
3Peter
4Frank
5
Summary
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,381
Members
448,888
Latest member
Arle8907

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