Transpose? based on common values

63falcondude

Well-known Member
Joined
Jan 15, 2016
Messages
3,572
Hey guys, I am looking to make a list of this form:

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Product Number[/TD]
[TD="align: center"]Avail Colors[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]62114[/TD]
[TD="align: center"]Blue[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]62114[/TD]
[TD="align: center"]Orange[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]62114[/TD]
[TD="align: center"]Red[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]62895[/TD]
[TD="align: center"]Red[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]62951[/TD]
[TD="align: center"]Purple[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]62951[/TD]
[TD="align: center"]Green[/TD]
[/TR]
</tbody>[/TABLE]


Into a list of this form:

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Product Number[/TD]
[TD="align: center"]Avail Colors[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]62114[/TD]
[TD="align: center"]Blue[/TD]
[TD="align: center"]Orange[/TD]
[TD="align: center"]Red[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]62895[/TD]
[TD="align: center"]Red[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]62951[/TD]
[TD="align: center"]Purple[/TD]
[TD="align: center"]Green[/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]


Basically doing a transpose of the Avail Colors for each Product Number.

Any help with this is much appreciated.
 
What you wanted to do is physically change your existing table to the transposed table in place (that is, the new table overwrites the existing table), correct? If so, give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub RearrangeAvailableColors()
  Dim LastRow As Long, Ar As Range
  LastRow = Cells(Rows.Count, "A").End(xlUp).Row
  Range("A2:A" & LastRow) = Evaluate("IF(A2:A" & LastRow & "=A1:A" & LastRow - 1 & ","""",A2:A" & LastRow & ")")
  For Each Ar In Range("A2:A" & LastRow).SpecialCells(xlBlanks).Areas
    Ar.Offset(-1, 1).Resize(, Ar.Count + 1) = Application.Transpose(Ar.Offset(-1, 1).Resize(Ar.Count + 1))
  Next
  Range("A2:A" & LastRow).SpecialCells(xlBlanks).EntireRow.Delete
End Sub[/td]
[/tr]
[/table]
 
Upvote 0

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