Runtime Error 9 - Subscript out of range

starchildren3317

New Member
Joined
May 17, 2011
Messages
6
Good Morning Community,

I have a worksheet named AppSelect and when it gets activated I am trying to copy a row from another worksheet within the same workbook to this active worksheet.

Here is the code that I have to do such:

Code:
Private Sub Worksheet_Activate()

With Worksheets("Skills").Range("A2")
    .Range(.Cells(1), .End(xlToRight)).Copy Destination:=Worksheets("AppSelect").Range("A1")
End With

End Sub

When I activate the sheet however, I get this error:

Run-time Error '9':
Subscript out of range

It seems to be failing out on this line:

Code:
With Worksheets("Skills").Range("A2")

The Skills worksheet does exist and it is not misspelled so I am not really sure what it is choking. Any ideas?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
make sure the worksheet name is spelled correct "SKILLS"
and that the other worksheet name is correct and does exist
 
Upvote 0
It does, looking around with that error, I have seen many people suggesting the same thing that is why I double checked before posting and put down at the end:

The Skills worksheet does exist and it is not misspelled

I solved the issue, but I do not know why it wasn't working the way I had it.
Skills is the second worksheet in the workbook
So basically instead of this:
Code:
With Worksheets("Skills").Range("A2")

I wrote it as
Code:
With Worksheets(2).Range("A2")

And that seemed to solve everything. I would like to know what is going so that I don't have to rely on the "Skills" worksheet to be the second sheet.
 
Upvote 0
Is 'Skills' definitely the name on the worksheet tab and not it's codename?

The codename is what you see in the VBE explorer before the worksheet tab name, which is in parentheses.
 
Upvote 0
Also, it's very common for there to be a SPACE at the end of the tab name.
So it still appears to be "Skills", when in fact it's "Skills "

What does this return

MsgBox "|" & Worksheets(2).Name & "|"

Is it |Skills|
or |Skills |
or | Skills|
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top