Forum Discussion
Juergen_Thoma
May 17, 2021Copper Contributor
Consolidate a list based on identical values in one column
Hello together, I got a some kind of a specific issue. I got an Excel file with 2 columns, skus in the first column and all their categories in the second. There are multiple links for every sku ...
- May 17, 2021
Like this:
Sub Transform() Dim wshS As Worksheet Dim wshT As Worksheet Dim s As Long Dim m As Long Dim t As Long Dim c As Long Application.ScreenUpdating = False Set wshS = Worksheets("Current List") Set wshT = Worksheets("Result") wshT.Range("A2:A" & wshT.Rows.Count).EntireRow.Clear m = wshS.Range("A" & wshS.Rows.Count).End(xlUp).Row t = 1 For s = 2 To m If wshS.Cells(s, 1).Value <> wshS.Cells(s - 1, 1).Value Then t = t + 1 wshT.Cells(t, 1).EntireRow.NumberFormat = "@" wshT.Cells(t, 1).Value = wshS.Cells(s, 1).Value c = 1 End If c = c + 1 wshT.Cells(t, c).Value = wshS.Cells(s, 2).Value Next s Application.ScreenUpdating = True End Sub(But PowerQuery might well be better)
Riny_van_Eekelen
May 17, 2021Platinum Contributor
Juergen_Thoma Added a query (connecting to a copy of the "Current List") to your file producing the desired results. See if you can get it to work on your real data.