Run-time error '1004'

G

Guest

See discussion thread below. Any help is greatly
appreciated.
G
***************************
Hi Nick,
Thx a ton for the earlier msg. Saw it only today.
I did try the suggestion you had and I am still getting
the same error.
Any help is greatly appreciated.
Thx
G
 
G

g

It is just a one-line command that resides in the
ThisWorkbook module. The whole code is

Private Sub Workbook_Open()
Sheets(4).Select
End Sub

Basically, I'm making sure xl opens the sheet4 spreadsheet
when the file is opened (irrespective of which worksheet
tab was open when the file was last saved).
Thanks a lot for the help.
G
 
R

Robert Rosenberg

Try:

Private Sub Workbook_Open()
On Error Resume Next
ThisWorkbook.Sheets(4).Activate
End Sub

I've added "ThisWorkbook" to insure that the macro doesn't attempt to select
the 4th sheet on any other open workbook. I've also changed ".Select" to
".Activate" only because I prefer it (its the newer syntax) - its not the
reason you're code would fail. Finally, I added the On Error line so that
you don't encounter an error if there is no 4th sheet .
--
_________________________
Robert Rosenberg
R-COR Consulting Services
Microsoft MVP - Excel
http://www.r-cor.com
 
G

Guest

Hi Robert,
Just saw the e-mail today. Thanks a lot for the
suggestion. Will see if it works.
G
 
G

Guest

Ok, so I tried the newer code. This time the error dialog
box does not pop-up (i guess due to the On Error... etc
line in the code) but the macro does not work either. I
know sheet 4 exists since the macro works fine if the one
other file that I mentioned earlier (pls see below) is not
open.
The errror happens only if another particular file is open.
Thx
 

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

Similar Threads


Top