Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Startup Code in a Workbook

Are there similar EVENTs in Excel operating on the Workbook or Sheets, as
there are in Access that will execute against FORMS, i.e. 'On Open', 'On
Activate'.

I want to execute some code when certain sheets are accessed in my workbook.

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Startup Code in a Workbook

There are a bunch of events. They are accessed from two places. One is the
worksheets and the other is the "ThisWorkbook" object. In the VB window just
above the code window you will see two drop downs. The one on the left says
General. Change it to Worksheet or ... and a code procedure will be
automatically entered into the code window for you (delete it if it is not
the one you want). The drop down to the right lists all of the events for
that object (Sheet, ThisWorkbook, embeded controls...).

Modules do not have events. Forms can have events but it sounds like you are
familiar with this concept. Classes can have events but that is a little more
explanation than I am prepared to get into...
--
HTH...

Jim Thomlinson


"BFarrell" wrote:

Are there similar EVENTs in Excel operating on the Workbook or Sheets, as
there are in Access that will execute against FORMS, i.e. 'On Open', 'On
Activate'.

I want to execute some code when certain sheets are accessed in my workbook.

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Startup Code in a Workbook

http://www.cpearson.com/excel/events.htm

might be a start.

--
Regards,
Tom Ogilvy

"BFarrell" wrote in message
...
Are there similar EVENTs in Excel operating on the Workbook or Sheets, as
there are in Access that will execute against FORMS, i.e. 'On Open', 'On
Activate'.

I want to execute some code when certain sheets are accessed in my

workbook.

Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Startup Code in a Workbook

Yes - you can do what you want with the Workbook_SheetActivate event. To get
to them go into the VBA editor. Make sure Project Explorer is showing (View
menu). Double-click on the line for your current project that says
"ThisWorkbook." That puts you into the workbook's code module.

Now at the top of the code pane are two dropdown lists. From the one on the
left choose "Workbook" and then the one on the right will show all the events
for the workbook. Choose the one you want to use, e.g. SheetActivate, and
the editor will create the "skeleton" event procedure for you:
Private Sub Workbook_SheetActivate(ByVal Sh As Object)

End Sub
In the above example the variable Sh will be the Worksheet you just
activated so you can identify it and use it in your code.

For more info look into the Excel VBA Help files - Look at the Excel VBA
Language Reference under the section "Events".
--
- K Dales


"BFarrell" wrote:

Are there similar EVENTs in Excel operating on the Workbook or Sheets, as
there are in Access that will execute against FORMS, i.e. 'On Open', 'On
Activate'.

I want to execute some code when certain sheets are accessed in my workbook.

Thanks!

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
Stop window saying code execution interrupted at startup? Jerry07 Excel Discussion (Misc queries) 1 August 15th 09 05:16 PM
No Workbook at Startup Paul Martin[_2_] Excel Discussion (Misc queries) 4 July 23rd 08 02:04 AM
Forms at workbook startup Jaytee Excel Discussion (Misc queries) 2 January 16th 07 02:42 PM
Startup Workbook kent Setting up and Configuration of Excel 16 October 10th 06 11:19 PM
Workbook startup condition wikegolfa Excel Discussion (Misc queries) 3 December 16th 04 03:11 PM


All times are GMT +1. The time now is 08:33 AM.

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"