Sub Compare2sheets()
Dim ws1 As Workbook, ws2 As Workbook
Dim s1 As String, s2 As String
s1 = InputBox("Enter 1st sheet name")
s2 = InputBox("Enter 2nd sheet name")
Set ws1 = Sheets("s1")
Set ws2 = Sheets("s2")
Dim rcount As Long, ccount As Long
rcount = ws1.UsedRange.Rows.Count
ccount = ws1.UsedRange.Columns.Count
Dim r As Long, c As Integer
For r = 1 To rcount
For c = 1 To ccount
If ws1.Cells(r, c) <> ws2.Cells(r, c) Then
ws2.Cells(r, c).Interior.ColorIndex = 6
End If
Next c
Next r
Set ws1 = Nothing
Set ws2 = Nothing
End Sub
问题:我无法执行上述代码。如何执行此代码?