Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mr. Novice again. . .
I have a macro to do some actions on data that I want to invoke when they select the tab. Also, I want to invoke some data clearing actions for when they leave the tab and go somewhere else. Can someone share the commands to start macros when entering or leaving a sheet? Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mr Novice,
to trigger code place it in appropriate event procedure in worksheet module. To get to a module right click a sheet tabView Codechange left drop down list from General to Worksheet select the appropriate Event procedure from the right drop down list where you should see Activate and Deactivate. Ken Johnson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mr Novice,
Maybe I went a bit too fast there. I should have started by saying that there are no commands for starting macros when entering (Activating) or leaving (Deactivating) a sheet. Instead, the code is triggered by either placing the code inside an event procedure or calling your code from an event procedure. The start and end lines for these event procedures are found in the worksheet modules. Say you already have a macro called macro1 and you want it to start running when sheet1 is activated, then you could either type its name between the ready supplied start and finish line: Private Sub Worksheet_Activate() macro1 End Sub or paste the code there. Either way, macro1 is then automatically run whenever sheet1 is activated. Similarly for the deactivate event sub. Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Invoking macro to insert rows according to DDE imported data | New Users to Excel | |||
Invoking a Visual Basic macro from a Custom Toolbar Button | Excel Worksheet Functions | |||
Switching woorkbooks & and invoking a macro from within a macro | Excel Programming | |||
Excel Macro Code invoking InputBox. | Excel Programming |