Sub 新旧比较() 'bajifeng
ofn = Array("表1.xlsx", "表2.xlsx")
Application.DisplayAlerts = False
Workbooks.Open ThisWorkbook.Path & "" & ofn(0)
arr = ActiveWorkbook.ActiveSheet.UsedRange
ActiveWorkbook.Close
Workbooks.Open ThisWorkbook.Path & "" & ofn(1)
brr = ActiveWorkbook.ActiveSheet.UsedRange
crr = ActiveWorkbook.ActiveSheet.UsedRange
ActiveWorkbook.Close
[a1].Resize(UBound(brr), 7) = crr
For i = 2 To UBound(brr)
For j = 1 To 7
If arr(i, j) <> "" And brr(i, j) <> "" And arr(i, j) <> brr(i, j) Then Cells(i, j).Font.ColorIndex = 3
If arr(i, j) = "" And brr(i, j) <> "" Then Cells(i, j).Font.ColorIndex = 4
If arr(i, j) <> "" And brr(i, j) = "" Then
Cells(i, j).Value = arr(i, j)
Cells(i, j).Font.ColorIndex = 15
End If
Next
Next
Application.DisplayAlerts = True
End Sub