Try this:
Sub SteinV(): Dim P, Q, r As Long, s As Long, wa As Worksheet
Dim ID As String, n As Long, k As Long: s = 2
Set wa = Sheets("Daily Input")
If ActiveSheet.Name <> wa.Name Then Exit Sub
wa.AutoFilterMode = False
P = wa.Cells(1, 1).CurrentRegion: wa.UsedRange.Offset(1).ClearContents
Q = wa.Cells(1, 1).Resize(UBound(P, 1), UBound(P, 2) + 1)
With CreateObject("Scripting.Dictionary")
For r = 2 To UBound(P, 1)
ID = P(r, 4) & "|" & P(r, 9) & "|" & P(r, 26) & "|" & P(r, 35)
P(r, 13) = P(r, 11) * P(r, 13)
If ID <> "" Then
If .Exists(ID) Then
k = .Item(ID): Q(k, 11) = Q(k, 11) + P(r, 11): Q(k, 13) = Q(k, 13) + P(r, 13)
Else: .Item(ID) = s
For n = 1 To UBound(P, 2): Q(s, n) = P(r, n): Next n: s = s + 1
End If
Else
For n = 1 To UBound(P, 2): Q(s, n) = P(r, n): Next n: s = s + 1
End If: Next r: k = s
For r = 2 To s - 1: Q(r, 13) = Q(r, 13) / Q(r, 11): Next r
wa.Cells(1, 1).Resize(UBound(Q, 1), UBound(Q, 2)) = Q
End With
End Sub
Bookmarks