Copy an entire row from sheet 2 which contains any value from column A on sheet 1
Clash Royale CLAN TAG#URR8PPP
Copy an entire row from sheet 2 which contains any value from column A on sheet 1
I would like to be able to copy any row from sheet 2 which contains any value from column a in sheet 1. I so far have this code but keep getting subscript out of range errors. Any help would greatly be appreciated. Thanks
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
If MyCell.Value = MyRange.Value
Cell
If
Do you understand that you're iterating over single cell?
– JohnyL
Aug 12 at 17:45
Also you're doing
.copy
but not .paste
...– Marcucciboy2
Aug 13 at 13:28
.copy
.paste
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Do you mean
If MyCell.Value = MyRange.Value
? There is no variable here defined asCell
so something is off in yourIf
statement– urdearboy
Aug 12 at 15:59