Forum Discussion
SuperNova53
Jan 30, 2020Copper Contributor
Help With Run-Time Error 9
Hi, I was hoping that you guys might be able to help me with an issue I'm having. I can't seem to get my Macro to work correctly and can't for the life of me figure out why! It should copy ro...
Riny_van_Eekelen
Jan 31, 2020Platinum Contributor
Replace the codes where you determine variable a and b like this:
a = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
and
b = Worksheets("Sheet5").Range("A" & Rows.Count).End(xlUp).Row
Then it should work.
EDIT: Looked at your original code again. Saw you have "x1Up" in the code that sets a and b. Change it to "xlUP" and it will work as well. So type the letter "L" in stead of number "1".
SuperNova53
Jan 31, 2020Copper Contributor
Hi, thank you for your advice. I have corrected the code as advised, but I'm still getting the same error message. I'm stumped as to what is the cause, when I run the Debug it highlights the second line in yellow.
- Riny_van_EekelenJan 31, 2020Platinum Contributor
Your corrected code, my code or both?
Both codes worked for me in the test sheet I created myself. Perhaps something else causes the error.