|
楼主 |
发表于 2012-3-26 22:31
|
显示全部楼层
http://club.excelhome.net/thread-752409-1-2.html
这段收集备用。。。
Sub Macro1()
Dim d(1 To 2) As Object, arr(1 To 2), i&, l&, t
For l = 1 To 2
Set d(l) = CreateObject("scripting.dictionary")
arr(l) = Sheets(l).[a1].CurrentRegion
For i = 2 To UBound(arr(l))
If arr(l)(i, 1) = 1 Then d(l)(arr(l)(i, 2)) = i
Next
Next
For i = 2 To UBound(arr(1))
If arr(1)(i, 1) = 1 Then
If d(1).Exists(arr(1)(i, 2)) And d(2).Exists(arr(1)(i, 2)) Then
d(1).Remove (arr(1)(i, 2))
d(2).Remove (arr(1)(i, 2))
End If
End If
Next
For l = 1 To 2
With Sheets(l)
.[b:b].Interior.ColorIndex = xlNone
t = d(l).Items
For i = 0 To UBound(t)
.Cells(t(i), 2).Interior.ColorIndex = 3
Next
End With
Next
End Sub
|
|