So I know this question has been asked time and time again, but going through all the posts and creating code, I can't seem to get mine to work. I've attached an example of what my data looks like and what I need it to look like. My issue is the code is pasting the first column, which I don't want, and it isn't adding all the duplicate rows together.
what data looks like (Data), needs to look like (Need), and is coming out as(Get):
The code I have tried is the following:
Dim ar As Variant
Dim i As Long
Dim j As Long
Dim n As Long
Dim str As String
n = 2
ar = Worksheets("bom_wo_header").Cells(4, 1).CurrentRegion.value
With CreateObject("Scripting.Dictionary")
For i = 3 To UBound(ar, 1)
str = ar(i, 5)
If Not .exists(str) Then
n = n + 1
For j = 1 To UBound(ar, 2)
ar(n, j) = ar(i, j)
Next j
.Item(str) = n
Else
j = 3
ar(.Item(str), j) = ar(.Item(str), j) + ar(i, j)
End If
Next i
End With
Worksheets("totals").Range("A1").Resize(n, UBound(ar, 2)).value = ar