View Full Version : Expand 2 Columns to Multiple Columns with unique ID Rows

01-25-2013, 06:19 AM
I am going nuts trying to figure this out, I looked a transpose and Test to Columns and just know its something straight forward and I'm just not searching with the right questions.
I have 2 Columns of Data 1. [Location ID] 2. [Product ID] and I want to show a unique [Location ID] with the [Product ID] expanded across the single row With 4 New Column Headings and then if possible sort each row under the new Product ID Headings in descending order. Not clear I know but hers is a sample of what I mean. Any help would be greatly appreciated
Please See Attached for Before and After Examples:

01-25-2013, 06:23 AM
Found VBA to sort the Rows, very handy Macro: See Below

Sub Test()
Dim RgToSort As Range
Dim RgRow As Range
Dim x As Long

Set RgToSort = Range(Range("B1:F1"), Range("B1:F1").End(xlDown))

For Each RgRow In RgToSort.Rows
RgRow.Sort Key1:=Range(RgRow.Item(1).Address), Order1:=xlAscending, Orientation:=xlLeftToRight, OrderCustom:=1

End Sub