在两张纸之间复制单元格

我想要做的只是根据单元格的内容将信息从一个表格复制到另一个表格。 基本上,如果来自列A,表1中的数字与列A,表2中的数字相匹配,我希望它将来自表2的整个行复制到表1中,在匹配的行旁边两个单元格分隔

任何帮助将不胜感激! 请让我知道,如果你需要更多的澄清。

For i = 1 to EndofColumnInSheet1 if (There is a match with xNumber in sheet 2) { Copy entire row in Sheet 2 beside matching row in Sheet 1 } else { Keep entire row empty. AKA Skip this row. } 

这个简单的循环似乎运行相当快。

 Dim r As Long, cc As Long, cr As Long, ws1 As Worksheet, ws2 As Worksheet Set ws1 = Sheets("Sheet10") Set ws2 = Sheets("Sheet11") With ws1 For r = 1 To .Cells(Rows.Count, 1).End(xlUp).Row If CBool(Application.CountIf(ws2.Columns(1), .Cells(r, 1).Value)) Then cr = Application.Match(.Cells(r, 1).Value, ws2.Columns(1), 0) cc = ws2.Cells(cr, Columns.Count).End(xlToLeft).Column .Cells(r, 4).Resize(1, cc) = ws2.Cells(cr, 1).Resize(1, cc).Value Else 'do nothing End If Next r End With Set ws2 = Nothing Set ws1 = Nothing