|
楼主 |
发表于 2024-11-12 08:19
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
多谢。参照第一个代码修改了一下:
Sub Macro1()
'两工作表限定区域单元格比对
Dim oSht1 As Worksheet, oSht2 As Worksheet
Set oSht1 = Sheets(2)
Set oSht2 = Sheets(3)
Application.ScreenUpdating = False
With oSht1.Range("C6:K17")
.Interior.Pattern = xlNone
arr1 = .Value
iRow = .Cells(1).Row - 1
iCol = .Cells(1).Column - 1
End With
With oSht2.Range("C6:K17")
.Interior.Pattern = xlNone
arr2 = .Value
End With
For i = LBound(arr1) To UBound(arr1)
For j = LBound(arr1, 2) To UBound(arr1, 2)
If arr1(i, j) <> arr2(i, j) Then
oSht1.Cells(iRow + i, iCol + j).Interior.Color = vbYellow
oSht2.Cells(iRow + i, iCol + j).Interior.Color = vbYellow
End If
Next
Next
Application.ScreenUpdating = True
End Sub
|
|