Hi there
What does this code mean, I attach the sample excel sheet that I provided but its not quite right. Basically I have a list of data - which includes overtime per employee. There are different rates and the list includes overtime recorded on different days - the days have been removed. I just need the total overtime per rate per employee so as I can import the information in to payroll for payment.
Sub ertert() 'http://www.excelforum.com/excel-programming/803510-code-to-subtotal-per-employee-per-component.html
Dim x, y(), i&, j&, k&
x = Range("A1:D" & Cells(Rows.Count, 1).End(xlUp).Row).Value
ReDim y(1 To UBound(x), 1 To 4)
With CreateObject("Scripting.Dictionary")
.CompareMode = 1
For i = 1 To UBound(x)
If .Exists(x(i, 2)) Then
k = .Item(x(i, 2)): y(k, 4) = y(k, 4) + x(i, 4)
Else
j = j + 1: .Item(x(i, 2)) = j
For k = 1 To 4: y(j, k) = x(i, k): Next k
End If
Next i
End With
[F:I].ClearContents: [f1:i1].Resize(j).Value = y()
End Sub
Bookmarks