0
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

Q:異なるワークブックの 2 つのシートを比較しようとしましたが、上記のコードを実行できません。

4

1 に答える 1