Selected Answer
Hi again Maklil
In the attached revised file, I redefined the dictionary index to include the price from column G (7) e.g. CR CCR-1;12000; see comments and changes in bold below:
Sub test()
Dim ws As Worksheet, a, i As Long, w, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
Set ws = Sheets("CA")
a = ws.Cells(1).CurrentRegion.Value
For i = 2 To UBound(a, 1)
If a(i, 2) <> "" Then
'check if dictionary item exists for Batch AND Price
If Not dic.exists(a(i, 2) & ":" & a(i, 7)) Then
ReDim w(1 To 8)
w(2) = a(i, 2)
w(7) = a(i, 7)
Else
' if not, add to dictionary item for Batch AND Price
w = dic(a(i, 2) & ":" & a(i, 7))
End If
w(2) = a(i, 2): w(3) = a(i, 3): w(4) = a(i, 4): w(5) = a(i, 5): w(6) = w(6) + a(i, 6): w(7) = a(i, 7): w(8) = w(6) * w(7)
dic(a(i, 2) & ":" & a(i, 7)) = w
End If
Next
With Sheets("Results1").Cells(1).CurrentRegion
.Offset(1).ClearContents
If dic.Count Then
With .Rows(2).Resize(dic.Count)
.Value = Application.Index(dic.items, 0, 0)
.Columns(1) = Evaluate("row(1:" & .Rows.Count & ")")
End With
End If
End With
End Sub
Note that the values are written to a new sheet called "Results1". You'll need to add code to calucalute the total and any formatting you want.
Hope this fixes your problem- if so, please remeber to mark this Answer as Selected.