Sub compare2sheetsex() 'and highlight the diffrence
Dim wb1 As Workbook, wb2 As Workbook, sh1 As Worksheet, sh2 As Worksheet
Set wb1 = Workbooks(InputBox("enter b1"))
Set wb2 = Workbooks(InputBox("enter b2"))
Set sh1 = wb1.Sheets(InputBox("enter s1"))
Set sh2 = wb2.Sheets(InputBox("enter s2"))
rcount = sh1.UsedRange.Rows.Count
ccount = sh1.UsedRange.Columns.Count
Dim r As Long, c As Integer
For r = 1 To rcount
For c = 1 To ccount
If sh1.Cells(r, c) <> sh2.Cells(r, c) Then
sh2.Cells(r, c).Interior.ColorIndex = 6
End If
Next c
Next r
Set sh1 = Nothing
Set sh2 = Nothing
End Sub
问:我尝试比较不同工作簿中的 2 张工作表,但无法执行上面的代码。