Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Sheet activate question

I have 5 sheets that each process "Worksheet_Activate()". When
my workbook first opens, Sheet1 is automatically selected by
default as the first active sheet, however it does not receive any
"Activate" event when the workbook is first loaded.

What is a good way to ensure that the default activated sheet's
"Worksheet_Activate()" handler is called??

thank you!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Sheet activate question

Hi Robert

Just put something like this in the ThisWorkbook module

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

Then when sheet1 is activated the worksheet_activate code will run on
that sheet.

Take care

Marcus

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Sheet activate question

Hi marcus,

I tried that, but it doesn't work. Since Sheet1 is automatically
active upon Workbook_Open, it does NOT get sent
an activated message, so Workbook_Open() does not get called.



"marcus" wrote in message
...

Just put something like this in the ThisWorkbook module

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

Then when sheet1 is activated the worksheet_activate code will run on
that sheet.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 199
Default Sheet activate question

How about this one?

Private Sub Workbook_Open()
Application.DisplayAlerts = False
Worksheets.Add
ActiveSheet.Delete
Worksheets("Sheet1").Activate
End Sub

Keiji

Robert Crandal wrote:
I have 5 sheets that each process "Worksheet_Activate()". When
my workbook first opens, Sheet1 is automatically selected by
default as the first active sheet, however it does not receive any
"Activate" event when the workbook is first loaded.

What is a good way to ensure that the default activated sheet's
"Worksheet_Activate()" handler is called??

thank you!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Sheet activate question

Change Private to Public Sub Worksheet_Activate()

Private Sub Workbook_Open()

Set ws = Sheet1 ' or Worksheets("Sheet1")

On Error GoTo errH
If ws Is ActiveSheet Then
Call ws.Worksheet_Activate
End If

Exit Sub
errH:
If Err = 438 Then
Debug.Print ws.Name; "_Worksheet_Activate doesn't exist " & _
"or is Private"
Else
Debug.Print Err.Description
End If

End Sub

If you want to call the activate event on any sheet that happens to be
active as the workbook opens start with -

ws = activesheet

There are probably better ways to acheive the same overall objective

Regards,
Peter T


"Robert Crandal" wrote in message
...
I have 5 sheets that each process "Worksheet_Activate()". When
my workbook first opens, Sheet1 is automatically selected by
default as the first active sheet, however it does not receive any
"Activate" event when the workbook is first loaded.

What is a good way to ensure that the default activated sheet's
"Worksheet_Activate()" handler is called??

thank you!




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activate Object question Eva Excel Worksheet Functions 0 December 14th 07 12:41 AM
Activate Object question Eva Excel Worksheet Functions 0 December 14th 07 12:41 AM
ThisWorkbook.Activate Question [email protected] Excel Programming 5 July 5th 07 06:52 PM
Return to Current Sheet in On (sheet activate) event macro Paul Moles Excel Programming 1 March 27th 05 03:16 PM
Worksheet.activate question Tim Coddington Excel Programming 8 December 2nd 04 02:36 AM


All times are GMT +1. The time now is 04:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"