|
Sub pb()
Application.ScreenUpdating = 0
brr = Sheet1.Range("A1").CurrentRegion
Set dic1 = CreateObject("scripting.dictionary")
For i = 2 To UBound(brr)
If brr(i, 5) = "正常" Then
For j = 6 To UBound(brr, 2)
If brr(i, j) <> "" Then
dic1(brr(i, 2)) = dic1(brr(i, 2)) & "@" & brr(i, j)
Else
Exit For
End If
Next
End If
Next
c = Sheet1.Range("ZZ2").End(1).Column + 1
100:
arr = Sheet2.Range("A1").CurrentRegion
Set dic = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
dic(arr(i, 1)) = arr(i, 2)
Next
k = dic.keys
For i = 2 To UBound(brr)
If brr(i, 5) = "正常" Then
For j = 0 To UBound(k)
If dic(k(j)) > 0 And Not InStr(dic1(brr(i, 2)), k(j)) > 0 Then
brr(i, c) = k(j)
dic(k(j)) = dic(k(j)) - 1
Exit For
End If
Next
If brr(i, c) = "" Then
Application.Calculate
排序
GoTo 100:
End If
End If
Next
Sheet1.Range("A1").Resize(UBound(brr), UBound(brr, 2)) = brr
Application.ScreenUpdating = 1
End Sub |
评分
-
1
查看全部评分
-
|