hi there. do upload an excel sample so that we do not have to manually key in your data to do a testing.
try this code here:
Sub test()
LR = Cells(Rows.Count, 1).End(xlUp).Row
With Sheets("Desired Output")
.Cells(1, 1).Resize(LR, 2) = Cells(1, 1).Resize(LR, 2).Value
For RowX = LR To 2 Step -1
If .Cells(RowX, 1) = .Cells(RowX - 1, 1) Then
.Cells(RowX - 1, "B") = .Cells(RowX - 1, "B") & "," & .Cells(RowX, "B")
.Rows(RowX).Delete
End If
Next
.Activate
End With
MsgBox "Done!"
End Sub
How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
Bookmarks