I have this code
Code: Select all
Sub Test()
Dim rng As Range
Dim cl As Range
Set rng = Range(Range("B2"), Range("B" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each cl In rng
If Not .Exists(cl.Value) Then
.Add cl.Value, cl(, 2)
Else
.Item(cl.Value) = Application.Max(.Item(cl.Value), cl(, 2))
End If
Next cl
Range("J1").Resize(.Count, 3) = Application.Transpose(Array(.Keys, .Items))
End With
End Sub
First for the unique values (KEYS) and the the other column is the adjacent column for the maximum value
I need to add another column which is column D .. which has the value adjacent to the maximum value in column C
How can I add the items of the third column