删除a列中的重复项,相对应的b列的值保留最高值;
发布网友
发布时间:2022-05-12 00:29
我来回答
共1个回答
热心网友
时间:2023-10-29 20:07
'vba做很简单
Sub test()
Dim i, dic, t1, t2
[c:d].ClearContents
Set dic = CreateObject("scripting.dictionary")
For i = 1 To [a65536].End(xlUp).Row
t1 = Cells(i, 1): t2 = Cells(i, 2)
If Not dic.exists(t1) Then
dic.Add t1, t2
Else
If Val(t2) > Val(dic(t1)) Then dic(t1) = t2
End If
Next
[c1].Resize(dic.Count, 1) = WorksheetFunction.Transpose(dic.keys)
[d1].Resize(dic.Count, 1) = WorksheetFunction.Transpose(dic.items)
End Sub