ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem with VBA Code? (https://www.excelbanter.com/excel-programming/315400-problem-vba-code.html)

Steve[_71_]

Problem with VBA Code?
 
Can anyone tell me why this isn't working?

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

JulieD

Problem with VBA Code?
 
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

"Steve" wrote in message
...
Can anyone tell me why this isn't working?

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




Alasdair Stirling[_3_]

Problem with VBA Code?
 
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
"Steve" wrote:

Can anyone tell me why this isn't working?

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


Mike Mertes

Problem with VBA Code?
 
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

"Steve" wrote in message
...
Can anyone tell me why this isn't working?

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




Tom Ogilvy

Problem with VBA Code?
 
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

--
Regards,
Tom Ogilvy

"Steve" wrote in message
...
Can anyone tell me why this isn't working?

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




Tom Ogilvy

Problem with VBA Code?
 
That isn't an application level event. It is a workbook level event.

--
Regards,
Tom Ogilvy

"Mike Mertes" wrote in message
...
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

"Steve" wrote in message
...
Can anyone tell me why this isn't working?

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






Mike Mertes

Problem with VBA Code?
 
My mistake, you're right.

I was confusing it with the app_WorkbookOpen event.

-Mike

"Tom Ogilvy" wrote in message
...
That isn't an application level event. It is a workbook level event.

--
Regards,
Tom Ogilvy

"Mike Mertes" wrote in message
...
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

"Steve" wrote in message
...
Can anyone tell me why this isn't working?

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








Steve[_71_]

Problem with VBA Code?
 
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

"Steve" wrote:

Can anyone tell me why this isn't working?

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



All times are GMT +1. The time now is 12:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com