Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stop window saying code execution interrupted at startup? | Excel Discussion (Misc queries) | |||
No Workbook at Startup | Excel Discussion (Misc queries) | |||
Forms at workbook startup | Excel Discussion (Misc queries) | |||
Startup Workbook | Setting up and Configuration of Excel | |||
Workbook startup condition | Excel Discussion (Misc queries) |