|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
代码如下。。。
Sub test()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
Set sht = wb.Sheets("原始数据")
Set sh = wb.Sheets("账单数据")
sht.UsedRange.Interior.ColorIndex = xlNone
sh.UsedRange.Interior.ColorIndex = xlNone
arr = sht.[a1].CurrentRegion
brr = sh.[a1].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
s = arr(i, 8)
If Not d.exists(s) Then
d(s) = i
End If
Next
For i = 2 To UBound(brr)
s = brr(i, 8)
If d.exists(s) Then
For j = 1 To UBound(brr, 2)
If brr(i, j) <> arr(d(brr(i, 8)), j) Then
sh.Cells(i, 1).Resize(, UBound(brr, 2)).Interior.ColorIndex = 14
sht.Cells(d(brr(i, 8)), 1).Resize(, UBound(arr, 2)).Interior.ColorIndex = 4
sh.Cells(i, j).Font.ColorIndex = 3
sht.Cells(d(brr(i, 8)), j).Font.ColorIndex = 3
End If
Next
End If
Next
Set d = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub
|
|