多表比較(數(shù)組和Union方法)
Sub macro1()
'by:Northwolves
'2007年包裝工7月份-1.xls
On Error Resume Next
Dim sh As Worksheet, n As Long, i As Long, j As Long, ARR
Application.ScreenUpdating = False
For Each sh In Sheets
If sh.Name Like "D*" Then
n = sh.[A65536].End(xlUp).Row
ARR = sh.[a1].Resize(n, 8)
For i = 3 To n - 1
For j = i + 1 To n
If ARR(i, 1) & ARR(i, 2) = ARR(j, 1) & ARR(j, 2) Then
If Not ARR(i, 5) & ARR(i, 8) = ARR(j, 5) & ARR(j, 8) Then _ Union(sh.Cells(i, 2), sh.Cells(j, 2)).Interior.Color = vbRed
End If
Next j
Next i
End If
Next sh
Application.ScreenUpdating = True
End Sub
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點(diǎn)擊舉報。