"Collapse" Matrix?

dunnma

New Member
Joined
Dec 7, 2017
Messages
2
Given the following

AndyBobJeff
Bluex
Blackx
Purplex
Greenx
Yellowx
Redx
Brownx
Orangex

<tbody>
</tbody>

How can I get the output to be (or can I):

AndyBobJeff
BlueBlackPurple
GreenYellowRed
BrownOrange

<tbody>
</tbody>

I am struggling to even figure out what to call this for research on the net... UNknown number of columns/rows...

Thanks!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
If you are interested in a VBA solution then,

Assuming the names start from B1, and colors start from A2
And you are looking at the data on "Sheet3" and outputting the summary on "Sheet4", this is what the code looks like:
Code:
Sub CollapseMatrix()
    lr = Worksheets("Sheet3").Range("A" & Rows.Count).End(xlUp).Row
    lc = Worksheets("Sheet3").Cells(1, Columns.Count).End(xlToLeft).Column
    ColX = 2
    ColY = 1
    RowX = 1
    RowY = 1
    For i = ColX To lc
        For j = RowX To lr
            If j = 1 Then 'Transfer the name
                Worksheets("Sheet4").Cells(RowY, ColY).Value = Worksheets("Sheet3").Cells(j, i).Value
                RowY = RowY + 1
            ElseIf Worksheets("Sheet3").Cells(j, i).Value = "x" Then 'Transfer Colors
                Worksheets("Sheet4").Cells(RowY, ColY).Value = Worksheets("Sheet3").Range("A" & j).Value
                RowY = RowY + 1
            End If
        Next j
        RowY = 1
        ColY = ColY + 1
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,215
Members
448,874
Latest member
b1step2far

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