Runtime error with the sheet collection, which was not there in 20

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can any one help?
If you type the following code in a new workbook and execute, it throws runtime error 9 "subscript out of range", while accessing the sheets collection. This was not there in previous versions.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim tmpWB As Workbook
Set tmpWB = Workbooks.Open("C:\Program Files\General Electric\DFSS Process\Databases9.14.98\208.Face-Centered_CCD.table", 0, True, 2)
Dim tmpSheet As New Worksheet
Dim s As String
s = Left("208.Face-Centered_CCD.table", 31)
MsgBox s
Set tmpSheet = Sheets(Left("208.Face-Centered_CCD.table", 31))
MsgBox tmpSheet.Name

End Sub
 
Laks,
This works for me, so I would assume your WB does not have a suitably named
worksheet.
Unless you don't really mean that the name of the sheet is the same as your
WB.

NickHK

Laks said:
Can any one help?
If you type the following code in a new workbook and execute, it throws
runtime error 9 "subscript out of range", while accessing the sheets
collection. This was not there in previous versions.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim tmpWB As Workbook
Set tmpWB = Workbooks.Open("C:\Program Files\General Electric\DFSS
Process\Databases9.14.98\208.Face-Centered_CCD.table", 0, True, 2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top