|
学习一下字典,打扰了
Sub test()
arr = Sheets("销售表").[b2].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
s = arr(i, 1) & arr(i, 2)
If Not d.exists(s) Then
Set d(s) = CreateObject("scripting.dictionary")
End If
d(s)(arr(i, 4)) = ""
Next
brr = Sheets("库存表").[b2].CurrentRegion
Set d1 = CreateObject("scripting.dictionary")
For i = 2 To UBound(brr)
s = brr(i, 1) & brr(i, 2)
If Not d1.exists(s) Then
Set d1(s) = CreateObject("scripting.dictionary")
End If
d1(s)(brr(i, 3)) = ""
Next
crr = Sheets("目标表").[a3].CurrentRegion
For i = 2 To UBound(crr)
s = crr(i, 1) & crr(i, 2)
crr(i, 3) = d1(s).Count
crr(i, 4) = d(s).Count
Next
Sheets("目标表").[a3].CurrentRegion = crr
End Sub |
评分
-
1
查看全部评分
-
|