RUNTIME ERROR '1004' --- Select method of worksheet class failed

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

Guest

Hi
I have a VB6 programming and try to select a worksheet by using the command "Sheets(t_sheet_no).Select". And it raises the error as captioned. I guess it is because some sheet is invisible. Is there any command to test if a sheet is selectable
Thank

ErrorHandler
Select Case Err.Numbe
Case 9
t_sheet_no = t_sheet_no +
If t_sheet_no > t_sheet_count The
Sheets(t_sheet_current).Selec
Resume nextWorkboo
End I
Sheets(t_sheet_no).Select ' <--- Error occurred this lin
Range("A1").Selec
Resum
Case Els
MsgBox Err.Number & " : " & Err.Source & "-->" & Err.Description, , "Error
Exit Su
End Selec
 
Dim ws As Worksheet
For Each ws In Worksheets
If ws.Visible = True Then ws.Select
Next ws

--
XL2002
Regards

William

(e-mail address removed)

| Hi,
| I have a VB6 programming and try to select a worksheet by using the
command "Sheets(t_sheet_no).Select". And it raises the error as captioned. I
guess it is because some sheet is invisible. Is there any command to test if
a sheet is selectable?
| Thanks
|
|
| ErrorHandler:
| Select Case Err.Number
| Case 91
| t_sheet_no = t_sheet_no + 1
| If t_sheet_no > t_sheet_count Then
| Sheets(t_sheet_current).Select
| Resume nextWorkbook
| End If
| Sheets(t_sheet_no).Select ' <--- Error occurred this line
| Range("A1").Select
| Resume
| Case Else
| MsgBox Err.Number & " : " & Err.Source & "-->" & Err.Description,
, "Error"
| Exit Sub
| End Select
|
 
Hi
Just as an additional comment: Why do you want to select the worksheet.
In most cases there's no reason to do this. You could just use the
object reference to this sheet to do your processing.

Try to avoid select and activate statements if possible
 
i have the same error when accessing a worksheet. part of my code is a
posted below..

Workbooks.Open Filename:="Sales.xls"
Sheets("Branch1").Select '==> this produces the error as quoted by th
subject


i need to copy the computations from the selected sheet to anothe
file.

any help would be appreciated. thanks in advance


-
jawe
 

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