Forum Discussion
GregSchedler
Apr 15, 2020Copper Contributor
Recorded Macro not working
I have a recorded Macro that is not working. The Run-time error '1004': error occurs at the xlToRight line. The error says "Application-defined or object-defined error". The same is happening in a m...
OliverScheurich
Oct 27, 2021Gold Contributor
Has this been solved? If not, let's assume that active cell is A2.
ActiveCell.Offset(-1, 0).Select
This command moves active cell to A1. If you had started in cell A1 it would have caused an error because you can't move 1 row up from cell A1.
Selection.End(xlToRight).Select
This command moves the active cell to XFD1.
ActiveCell.Offset(0, 1).Select
This causes an error because column XFD is the last column of the sheet. Active cell therefore can't be moved to XFE1.
ActiveCell.Offset(-1, 0).Range("A1").Select
ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.Select
To my understanding the code colored in orange isn't required here.