Hello everyone
I found this snippet of code that would summarize duplicates of data in columns A & B
Public Type product
name As String
pages As String
End Type
Sub GroupProducts()
Dim produkts() As product
Dim lastRow, i, j, n As Long
Dim found As Boolean
ReDim Products(1 To 1)
lastRow = Range("a1").End(xlDown).Row
For i = 2 To lastRow
found = False
For j = LBound(Products) To UBound(Products)
If Cells(i, 1).Value = Products(j).name Then
found = True
Products(j).pages = Products(j).pages & ", " & Cells(i, 2).Value
End If
Next j
If found = False Then
n = n + 1
ReDim Preserve Products(1 To n)
Products(n).name = Cells(i, 1).Value
Products(n).pages = Cells(i, 2).Value
End If
Cells(i, 1).Value = ""
Cells(i, 2).Value = ""
Next i
For i = LBound(Products) To UBound(Products)
Cells(i + 1, 1).Value = Products(i).name
Cells(i + 1, 2).Value = Products(i).pages
Next i
End Sub
I tested it but got an error 424 error (Object Required)
Can you guide me why it gives the error and how to fix it?
Bookmarks