Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 * |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatically Run a macro when a worksheet is selected
Hello,
I have been trying to add this type of code to a sheet when the sheet is built using VBA modules. I do not see how to plug the "Private Sub Worksheet_Activate()" code onto the new sheet module. I need to have this completly invisible to the user. How can we reference the new sheet module programatically? Any ideas appreciated. thank you, Scott -----Original Message----- "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 * . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Automatically Run a macro when a worksheet is selected
http://www.cpearson.com/excel/vbe.htm
-- Regards, Tom Ogilvy Scott wrote in message ... Hello, I have been trying to add this type of code to a sheet when the sheet is built using VBA modules. I do not see how to plug the "Private Sub Worksheet_Activate()" code onto the new sheet module. I need to have this completly invisible to the user. How can we reference the new sheet module programatically? Any ideas appreciated. thank you, Scott -----Original Message----- "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 * . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to run specific macro on selected worksheet? | Excel Discussion (Misc queries) | |||
Automatically copy selected information from one worksheet to anot | Excel Discussion (Misc queries) | |||
Repeating a Macro For Each Selected Worksheet | Excel Worksheet Functions | |||
Macro to Sort automatically when file/save is selected | Excel Discussion (Misc queries) | |||
How to run a macro when a worksheet is selected | Excel Worksheet Functions |