多表比较(数组和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 |
|