Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Invoking macro when a tab is selected

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Invoking macro when a tab is selected

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Invoking macro when a tab is selected

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
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
Invoking macro to insert rows according to DDE imported data chainastole New Users to Excel 1 June 2nd 07 01:49 AM
Invoking a Visual Basic macro from a Custom Toolbar Button [email protected] Excel Worksheet Functions 2 March 1st 07 10:48 AM
Switching woorkbooks & and invoking a macro from within a macro Bob Benjamin Excel Programming 8 January 11th 04 02:12 AM
Excel Macro Code invoking InputBox. Andrew Thorne Excel Programming 0 July 30th 03 10:23 PM


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

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

About Us

"It's about Microsoft Excel"