VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 编程开发 > vb >
  • excel vba教程之多表比较(数组和Union方法)

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

相关教程