|
学习一下字典,打扰了
Sub test()
arr = [a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
If Not d.exists(arr(i, 1)) Then
d(arr(i, 1)) = i
Else
r = d(arr(i, 1))
If arr(r, 3) > arr(i, 3) Then
d(arr(i, 1)) = i
End If
End If
Next
ReDim brr(1 To d.Count, 1 To 2)
For Each kk In d.keys
m = m + 1
brr(m, 1) = arr(d(kk), 1)
brr(m, 2) = arr(d(kk), 3)
Next
[e1].Resize(, 2) = Array("物料", "不含税价格")
[e1].CurrentRegion.Offset(1).ClearContents
[e2].Resize(m, 2) = brr
End Sub |
评分
-
1
查看全部评分
-
|