Seems like the registry of my sheet names is corrupted

Douga137

New Member
Joined
Oct 28, 2015
Messages
8
I have a single workbook application with 3 procedures and 1 function. One procedure calls the other two iteratively
When I try to reference a sheet using a statement like Worksheets("Data").Range("A1")... i get one of two messages
0ne is "subscript out of range" and the other is 'select method of range class failed" I have test code below that I put in the same workbook and executed and got 'select method of range class failed" from the first statement tried to execute.

Sub test()
Worksheets("Data").Range("C5:C215").Select
Worksheets("CompositePDF").Range("C5:C215").Select
Worksheets("FitPDFsht").Range("C5:C215").Select
End Sub

Suggestions are most welcome as I am getting frustrated!

Thanks
 
I even had vba print out a list of my sheet names and there were no blanks there,
Ok, what is the cell that it put this particular sheetname into ?
And given that cell, what does this formula return entered in that sheet
=LEN(A1)

Where A1 is the cell your script put that particular sheet's name in.
 
Upvote 0

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
jommo1 - strung the names all together and displayed them in a msgbox. I tacked on an 'x' to make sure the last one didn't have a space at the end. They were all clean of any unwanted spaces
 
Upvote 0
application. goto worksheets("FitPDFsht").ranges(C5:c216") statement caused a 'subscript out of range' message
The syntax should be

Code:
Application.Goto Worksheets("FitPDFsht").Range("C5:F216")

If you get a subscript error with that, it means you have misspelled the sheet name.
 
Upvote 0
I tacked on an 'x' to make sure the last one didn't have a space at the end.
What about the beginning of the tab's name ? It could be a space as well.

Make a new sheet called SheetList
Run this code
Code:
Sub ListSheets()
For Each ws In WorkSheets
    Sheets("SheetList").Range("A1000").End(xlup).Offset(1,0).Value = "x" & ws.Name & "X"
Next ws
End Sub

Now look at the list of names.
 
Upvote 0
Sorry shg, I'm new to foruming and my natural carelessness has got to be curbed - there was no 's' in the actual code Sorry
 
Upvote 0
Thanks all - I rebuilt the application from building blocks that still worked and now it works beautifully!
 
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,694
Members
449,179
Latest member
kfhw720

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