对比两个数据表的数据

Sub yy() 'hlly888

Cells.Interior.ColorIndex = xlNone

Application.ScreenUpdating = False

Dim dc As Object, arr, yrr, i&, j%, tim

tim = Timer

Set dc = CreateObject("scripting.dictionary")

arr = Sheet1.[a1].CurrentRegion

yrr = Sheet2.[a1].CurrentRegion

   For i = 1 To UBound(yrr)

       For j = 1 To UBound(yrr, 2)

           dc(yrr(i, j) & i & j) = ""

       Next

   Next

   For i = 1 To UBound(arr)

       For j = 1 To UBound(arr, 2)

           If Not dc.exists(arr(i, j) & i & j) Then Cells(i, j).Interior.ColorIndex = 3

       Next

   Next

   

Application.ScreenUpdating = True

MsgBox Format(Timer - tim, "0.00") & "秒"

End Sub

你可能感兴趣的:(对比两个数据表的数据)