Feb 12 2018 05:46 PM
when I run follow this code :
Sub copyCell() Worksheets("Sheet1").Range("A11").Copy Destination:=Worksheets("Sheet2").Range("E5") End Sub
then I run above code:
PS: Translation in English is :
when run error '9': index out of range
I don't know what wrong with the code above.
Feb 12 2018 07:54 PM
SolutionTo make this code run, you must have two sheets in the workbook, the first sheet must be called Sheet1, and destination sheet must be called Sheet2.
It depends on a specific sheet name.
You can pass the index of each sheet instead of the name as follows:
Sub copyCell() Worksheets(1).Range("A11").Copy Destination:=Worksheets(2).Range("E5") End Sub
Regards
Feb 12 2018 08:15 PM - edited Feb 12 2018 08:35 PM
You can set the breakpoint at the line where the error comes out. Then, you can add Watch to watch the expression state.
Reference link
Feb 12 2018 10:52 PM
Feb 12 2018 07:54 PM
SolutionTo make this code run, you must have two sheets in the workbook, the first sheet must be called Sheet1, and destination sheet must be called Sheet2.
It depends on a specific sheet name.
You can pass the index of each sheet instead of the name as follows:
Sub copyCell() Worksheets(1).Range("A11").Copy Destination:=Worksheets(2).Range("E5") End Sub
Regards