VBA 查找多列

VBA 查找多列

我正在尝试比较同一张表上的两个数据表,并在第三个表中显示匹配项。我可以让第三个表的第一列返回匹配项,但其他匹配项不会显示所有结果或根本不显示任何结果。以下是我目前拥有的代码,以及表格屏幕截图的链接。我对 VBA 非常陌生,任何信息都将不胜感激。

Sub CarrierNameMatch()
On Error Resume Next

For m = 3 To 100

Worksheets("Sheet1").Cells(m, 13).Value = Application.WorksheetFunction.VLookup( _
Worksheets("Sheet1").Cells(m, 8).Value, Worksheets("Sheet1").Range("A:D"), 1, 0)

Next

End Sub
Sub CarrierSCACMatch()

On Error Resume Next

For n = 3 To 100

Worksheets("Sheet1").Cells(n, 14).Value = Application.WorksheetFunction.VLookup( _
Worksheets("Sheet1").Cells(n, 9).Value, Worksheets("Sheet1").Range("A:D"), 2, 0)

Next

End Sub
Sub CarrierMCMatch()

On Error Resume Next

For o = 3 To 100

Worksheets("Sheet1").Cells(o, 15).Value = Application.WorksheetFunction.VLookup( _
Worksheets("Sheet1").Cells(o, 10).Value, Worksheets("Sheet1").Range("A:D"), 3, 0)

Next
End Sub
Sub CarrierDotMatch()

On Error Resume Next

For p = 3 To 100

Worksheets("Sheet1").Cells(p, 16).Value = Application.WorksheetFunction.VLookup( _
Worksheets("Sheet1").Cells(p, 11).Value, Worksheets("Sheet1").Range("A:D"), 4, 0)

Next

End Sub

工作表信息

相关内容