从工作表2复制整行,其中包含工作表1的A列中的任何值

时间:2018-08-12 13:20:48

标签: arrays excel excel-vba formula

我希望能够复制工作表2的任何行,其中包含工作表1的a列中的任何值。到目前为止,我拥有此代码,但始终使下标超出范围错误。任何帮助将不胜感激。谢谢

Sub test()
Dim MyCell As Range, MyRange As Range
Dim row_counter As Long, col_counter As Long

Set MyRange = Sheets(“Sheet1”).Range("A1")

For Each MyCell In MyRange
If Cell.Value = MyCell.Value Then
Cell.EntireRow.Copy
   End If

Next MyCell
End Sub

0 个答案:

没有答案