LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Automatically Run a macro when a worksheet is selected

"Stephen Hartman" wrote in message
...
Is there a bit of code that will automatically run a macro when I select the
worksheet that contains the macro?

Hi Stephen,

You can use the Worksheet_Activate event, which will fire whenever the sheet
is activated. Note that of the sheet is already active, clicking on its
sheet tab will not cause this event to fire. Place the following event
procedure in the code module behind the worksheet in question and add your
code to it:

Private Sub Worksheet_Activate()
''' Put your code here.
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *



 
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
How to run specific macro on selected worksheet? Harshad[_2_] Excel Discussion (Misc queries) 2 October 31st 08 06:56 AM
Automatically copy selected information from one worksheet to anot SM1 Excel Discussion (Misc queries) 1 December 21st 06 01:02 AM
Repeating a Macro For Each Selected Worksheet carl Excel Worksheet Functions 0 January 11th 06 10:07 PM
Macro to Sort automatically when file/save is selected KDG Excel Discussion (Misc queries) 3 December 20th 05 08:28 PM
How to run a macro when a worksheet is selected cpmittal Excel Worksheet Functions 2 July 27th 05 11:57 AM


All times are GMT +1. The time now is 11:55 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"