This will (should) generate a new sheet from your source file with merged duplicates.
To use the following code, you need to add it to the new module in the VBA editor
The shortcut to open the VBA editor is Alt+F11 (for Windows) and Alt+Fn+F11 (for Mac)
When the editor is open, add a new module by selecting it from the "insert" menu in the main menu bar. It should automatically open the module, ready to accept the code, if you do not need to select it (it will be called "ModuleN", where N is the next available number) from the project explorer.
I'm not sure if "Scripting.Dictionary" is available in osx, but it can't hurt to try.
Option Explicit Sub Main() Dim Source As Worksheet: Set Source = ThisWorkbook.Worksheets("Sheet1") Dim Destination As Worksheet: Set Destination = ThisWorkbook.Worksheets("Sheet2") Dim Records As Object: Set Records = CreateObject("Scripting.Dictionary") Dim Data As Variant Dim Index As Long Dim Row As Integer: Row = 1 Data = Source.Range("A1", "B" & Source.Rows(Source.UsedRange.Rows.Count).Row).Value2 For Index = LBound(Data, 1) To UBound(Data, 1) If Records.Exists(Data(Index, 1)) Then Destination.Cells(Records(Data(Index, 1)), 2).Value2 = Destination.Cells(Records(Data(Index, 1)), 2).Value2 & ", " & Data(Index, 2) Else Records.Add Data(Index, 1), Row Destination.Cells(Row, 1).Value2 = Data(Index, 1) Destination.Cells(Row, 2).Value2 = Data(Index, 2) Row = Row + 1 End If Next Index Set Records = Nothing End Sub
Nickslash
source share