Problem with VBA Code?

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

Guest

Can anyone tell me why this isn't working?

Private Sub Workbook_Open()
Worksheets("Sheet1").Activate
End Sub
 
Hi Steve

three ideas
1) you don't have a sheet called Sheet1
2) macros are not enabled (tools / macro /security - set to medium - choose
enable macros when asked)
3) it's not in the ThisWorkbook module of the workbook

Cheers
JulieD
 
There shouldn't be anything wrong with this code unless you have renamed
Sheet1 to some other name e.g. "NewName". If so you will have to change it
as follows:

Private Sub Workbook_Open()
Worksheets("NewName").Activate
End Sub

Regards,

Alasdair Stirling
 
I beleive that Application Events can only be handled from class modules.

You should be able to find the solution to your problem if you search for
"Application Events" in the VBA help, and find an article relating to,
"Using events with the application object."

Hope that helps.

-Mike
 
Assume you have Workbook_Open code you show in the ThisWorkbook module and
you have a sheet named Sheet1 in that workbook, then you might try the
following:

Private Sub Workbook_Open()
Thisworkbook.Worksheets("Sheet1").Activate
End Sub
 
That isn't an application level event. It is a workbook level event.
 
My mistake, you're right.

I was confusing it with the app_WorkbookOpen event.

-Mike
 
Guys I apologize. That is twice today I have had my head buried in a dark
hole. Everyonce in a while my excel here at work resets the Macro security
to high. That was the problem. Sorry for your wasting your time. But i do
appreciate the Quick and multiple responses. Thanks Guys and Gals.

Steve
 

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