I'm trying to understand why this bit of code works as a macro but fails in VBA. My workbook has 3 sheets, Sheet1, Referrals, Modified. I'm trying to select and copy rows from Referrals to Modified. This code segment is what was recorded as a macro when I physically selected row 2 from the Referrals sheet, clicked Copy, selected row 2 from the Modified sheet and clicked Paste. If I run the macro, it works great. I then pasted this code into my VBA app and it fails with a runtime error 1004, Select method of Range class failed, on the Rows("2:2").Select. There is data in the row and there is no data in the receiving row.
Eventually, it will be selecting based on a lookup but I'm just trying to get it to work with a hard code right now.
Sheets("Referrals").Select
Rows("2:2").Select
Selection.Copy
Sheets("Modified").Select
Rows("2:2").Select
ActiveSheet.Paste
Eventually, it will be selecting based on a lookup but I'm just trying to get it to work with a hard code right now.
Sheets("Referrals").Select
Rows("2:2").Select
Selection.Copy
Sheets("Modified").Select
Rows("2:2").Select
ActiveSheet.Paste