|
- Sub test()
- Dim Dic As Object, Dib As Object, Arr, i&, x%, tmPje As Double, zB%
- Set Dic = CreateObject("scripting.dictionary")
- Set Dib = CreateObject("scripting.dictionary")
- Arr = [B1].Resize(Cells(Rows.Count, "b").End(3).Row, 5)
- x = UBound(Arr, 1) - 1
- zB = 0
- Do While x > 0
- tmPje = 0
- Dic.RemoveAll: Dib.RemoveAll
- For i = 2 To UBound(Arr, 1)
- If Arr(i, 5) = "" Then
- If Not Dic.exists(Arr(i, 1)) Then Dic(Arr(i, 1)) = Arr(i, 3)
- If Dic(Arr(i, 1)) = Arr(i, 3) Then
- tmp = tmPje + Arr(i, 4)
- If tmp <= 100000 Then
- x = x - 1
- Arr(i, 5) = "Yes"
- tmPje = tmp
- Dib(i) = ""
- Else
- Exit For
- End If
- End If
- End If
- Next i
- zB = zB + 1
- For Each k In Dib.keys
- Arr(k, 5) = zB
- Next k
- Loop
- For i = 2 To UBound(Arr, 1) - 1
- For j = i + 1 To UBound(Arr, 1)
- If Arr(j, 5) < Arr(i, 5) Then
- For k = 1 To UBound(Arr, 2)
- tmp = Arr(i, k): Arr(i, k) = Arr(j, k): Arr(j, k) = tmp
- Next k
- End If
- Next j
- Next i
- [w1].Resize(UBound(Arr, 1), UBound(Arr, 2)) = Arr
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|