|
Sub test()
Set d = CreateObject("scripting.dictionary")
arr = Sheets("销").UsedRange
For j = 2 To UBound(arr)
If Not d.exists(arr(j, 3)) Then
Set d(arr(j, 3)) = CreateObject("scripting.dictionary")
End If
If Not d(arr(j, 3)).exists(arr(j, 6)) Then
Set d(arr(j, 3))(arr(j, 6)) = CreateObject("scripting.dictionary")
End If
d(arr(j, 3))(arr(j, 6))(j) = ""
Next j
arr = Sheets("财").UsedRange
For j = 2 To UBound(arr)
If d.exists(arr(j, 2)) Then
If d(arr(j, 2)).exists(arr(j, 4)) Then
If d(arr(j, 2))(arr(j, 4)).Count >= 1 Then
Cells(j, 1).Resize(1, 6).Interior.ColorIndex = 4
k = d(arr(j, 2))(arr(j, 4)).keys()(0)
Sheets("销").Cells(k, 1).Resize(1, 6).Interior.ColorIndex = 4
d(arr(j, 2))(arr(j, 4)).Remove k
Else
Cells(j, 1).Resize(1, 6).Interior.ColorIndex = 44
End If
Else
Cells(j, 1).Resize(1, 6).Interior.ColorIndex = 44
For Each k In d(arr(j, 2)).keys
For Each kk In d(arr(j, 2))(k).keys
Sheets("销").Cells(kk, 1).Resize(1, 6).Interior.ColorIndex = 44
Next kk
Next k
End If
End If
Next j
End Sub
|
|