Thanks:  0
Likes:  0

1. ## "Collapse" Matrix?

Given the following

 Andy Bob Jeff Blue x Black x Purple x Green x Yellow x Red x Brown x Orange x

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

 Andy Bob Jeff Blue Black Purple Green Yellow Red Brown Orange

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

Thanks!

2. ## Re: "Collapse" Matrix?

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```

3. ## Re: "Collapse" Matrix?

Beautiful! Did you crank this out or just happen to have it lying around?

4. ## Re: "Collapse" Matrix?

I cranked it out.