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!
|