I have two columns in excel like the following
a,apple
a,bannana
a,orange
a,plum
b,apple
b,berry
b,orange
b,grapefruit
c,melon
c,berry
c,kiwi
I need to consolidate them like this on a different sheet
a,apple,bannana,orange,plum
b,apple,berry,orange,grapefruit
c,melon,berry,kiwi
Any help would be appreciated
This code works but is way too slow. I have to cycle through 300000 entries.
Dim MyVar As String
Dim Col
Dim Var
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
' Select first line of data.
For Var = 1 To 132536
Sheets("Line Item Detail").Select
Range("G2").Select
' Set search variable value.
Var2 = "A" & Var
MyVar = Sheets("Sheet1").Range(Var2).Value
'Set Do loop to stop at empty cell.
Col = 1
Do Until IsEmpty(ActiveCell)
' Check active cell for search value.
If ActiveCell.Value = MyVar Then
Col = Col + 1
Sheets("Sheet1").Range(Var2).Offset(0, Col).Value = ActiveCell.Offset(0, 1).Value
End If
' Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select
Loop
Next Var
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True