Excel 比较两张表和表3上的结果

Excel 比较两张表和表3上的结果,excel,vba,Excel,Vba,下面的代码是我编辑得到的结果,但不幸的是得到它。我试图将表1的A和B栏与表2的A和B栏进行比较,并将结果显示在表3上。请告知 Sub ReconcileRegisters() Dim i As Long, _ LRa As Long, _ LRb As Long, _ rowx As Long LRa = Sheets("sheet1").Range("A1:B" & Rows.Count).End(xlUp).Row LRb = Sheets("sheet2").Range

下面的代码是我编辑得到的结果,但不幸的是得到它。我试图将表1的A和B栏与表2的A和B栏进行比较,并将结果显示在表3上。请告知

Sub ReconcileRegisters()
Dim i    As Long, _
LRa  As Long, _
LRb  As Long, _
rowx As Long

LRa = Sheets("sheet1").Range("A1:B" & Rows.Count).End(xlUp).Row
LRb = Sheets("sheet2").Range("A1:B" & Rows.Count).End(xlUp).Row
rowx = 2
Application.ScreenUpdating = False
For i = 2 To LRa
    If IsError(Application.Match(Sheets("sheet1").Range("A1:B" & i).Value, Sheets("sheet2").Range("A1:B" & LRb), 0)) Then
        Sheets("sheet3").Range("A" & rowx).Value = Sheets("sheet1").Range("A1:B" & i).Value
        rowx = rowx + 1
    End If
Next i
For i = 2 To LRb
    If IsError(Application.Match(Sheets("sheet2").Range("A1:B" & i).Value, Sheets("sheet1").Range("A1:B" & LRa), 0)) Then
        Sheets("sheet3").Range("A" & rowx).Value = Range("A1:B" & i).Value
        rowx = rowx + 1
    End If
Next i
Application.ScreenUpdating = True
MsgBox "Matching process is complete"

End Sub

如果您比较两个循环,那么我假设您在第二部分中需要
图纸(“sheet2”)

Sheets("sheet3").Range("A" & rowx).Value = Range("A1:B" & i).Value

你需要描述这个问题。您在哪一行收到了哪些错误?它怎么不起作用?