Hi,
assuming data from columns A to D, nothing in column E, starts in row 1,
code to paste directly to the worksheet module :
Sub Demo()
With [A1].CurrentRegion
ReDim RC(1 To .Rows.Count, 1 To 5): VA = .Value
For R& = 1 To .Rows.Count
V = Application.Match(VA(R, 2), Application.Index(RC, , 2), 0)
If IsError(V) Then
N& = N& + 1: RC(N, 5) = 1
For C% = 1 To 4: RC(N, C) = VA(R, C): Next
Else
RC(V, 5) = RC(V, 5) + 1
For C = 3 To 4: RC(V, C) = RC(V, C) + VA(R, C): Next
End If
Next
For R = 2 To N
If RC(R, 5) > 1 Then For C = 3 To 4: RC(R, C) = RC(R, C) / RC(R, 5): Next
Next
.Value = RC: Erase RC, VA
End With
End Sub
Enjoy it and don't forget to click on bottom left star « Add Reputation », thanks !
Bookmarks