See if this will work you?
Sub abc()
Const shRaw As String = "RawData" '<=== Change for your needs
Const shOutput As String = "Final" '<=== Change for your needs
Dim arrResults As Variant, a
Dim i As Long, ii As Long
With Worksheets(shRaw)
a = .Range("a1").CurrentRegion
End With
ReDim arrResults(1 To UBound(a), 1 To 4)
For i = 1 To UBound(a)
arrResults(i, 1) = a(i, 1)
arrResults(i, 2) = a(i, 2)
arrResults(i, 3) = a(i, 3)
For ii = 4 To UBound(a, 2)
If a(i, ii) = 1 Then
arrResults(i, 4) = arrResults(i, 4) & a(1, ii) & " ,"
End If
Next
If Not IsEmpty(arrResults(i, 4)) Then
arrResults(i, 4) = Left(arrResults(i, 4), Len(arrResults(i, 4)) - 2)
End If
Next
With Worksheets(shOutput)
Cells.Clear
With Range("a1").Resize(UBound(a), 4)
.Value = arrResults
.Borders.LineStyle = xlContinuous
End With
.Range("d1") = "Category"
.Cells.EntireColumn.AutoFit
End With
End Sub
Bookmarks