|
学习一下字典,打扰了
Sub test()
arr = Sheets("2").[a1].CurrentRegion
lastr = Sheets("1").Cells(Rows.Count, "a").End(xlUp).Row
brr = Sheets("1").Range("a3:b" & lastr)
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
If arr(i, 4) = brr(1, 2) Then
If Not d.exists(arr(i, 2)) Then
d(arr(i, 2)) = i
Else
r = d(arr(i, 2))
If arr(r, 3) < arr(i, 3) Then
d(arr(i, 2)) = i
End If
If arr(r, 3) = arr(i, 3) Then
If arr(r, 1) < arr(i, 1) Then
d(arr(i, 2)) = i
End If
End If
End If
End If
Next
For i = 2 To UBound(brr)
brr(i, 2) = arr(d(brr(i, 1)), 5)
Next
With Sheets("1")
.Columns(1).NumberFormat = "@"
.Columns(2).NumberFormat = "0.00"
.[a3].Resize(UBound(brr), UBound(brr, 2)) = brr
End With
End Sub
|
评分
-
1
查看全部评分
-
|