此代码尝试使用其最大值创建唯一名称列表,但是if Not Exists
存在一些错误。你能帮我解决这个问题吗?
Sub UniqeMAX()
Dim Rng As Range
Dim Dn As Range
Set Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In Rng
If Not.Exists(Dn.Value) Then
.Add Dn.Value, Dn(, 3)
Else
.Item(Dn.Value) = Application.max(.Item(Dn.Value), Dn(, 3))
End If
Next
Range("D1").Resize(.Count, 3) = Application.Transpose(Array(.Keys, .Items))
End With
End Sub