Run-time error '9' Subscript out of Range Help

Pookiemeister

Well-known Member
Joined
Jan 6, 2012
Messages
626
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I am getting a "Run-time error '9': Subscript out of range" on the following code:
Code:
Worksheets("Exhibit ""I""").Activate
The worksheet name is Exhibit "I". If I remember correctly about what that run-time error means, on this line of code its saying it can't find a sheet with that name to activate. I have a feeling it has something to due with all the quotes around the letter (I). Unfortunately, I can not rename this spreadsheet because it is within a public file on a server and I'm not the author of it. I tried different ways to change the worksheet name like adding in single quotes(') instead of double quotes(") but VBA would change that line of code to RED Letters. The only way I could rename the worksheet above so that entire line of code wouldn't be in RED Letters was to position the quotes as shown above. But it still gave me a Run-time error '9'. I never dealt with worksheet names with quotes in them so I'm at a loss on to fix this error. Thank you.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Thank you both for the quick reply. Unfortunately, I can't get either suggestion to work without getting a Run-time error '9'.
 
Upvote 0
mumps
Thank you for the suggestive link but from what I saw, that example had quotes around the worksheet name versus mine has quotes within a quote for my worksheet name.
 
Last edited:
Upvote 0
How about
Code:
Worksheets("Exhibit " & """I""").Activate
If that doesn't work run this
Code:
Sub chk()
Debug.Print "|" & ActiveSheet.Name & "|", Len(ActiveSheet.Name)
End Sub
and then copy the information from the immediate window to the thread
 
Upvote 0
Deleted as should have refreshed, response was the same as Fluff's first suggestion :(
 
Last edited:
Upvote 0
Fluff
The first suggestion didn't work. So here's the answer to the code Sub chk()

|Finished Goods Summary| 22

I know it returns the Activesheet name and its length but how is this code used to debug(troubleshoot)? Thank You.
 
Last edited:
Upvote 0
I should have said to select the Exhibit "I" sheet before running that code.
 
Upvote 0
After selecting the Exhibit "I" sheet it now returns
|Exhibit "I" | 12
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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