Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default execute macro on Worksheet selection

I would like to have a macro execute every time a specific Worksheet is
selected.

Thank You,
Bob carter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default execute macro on Worksheet selection

Hi Bob

Try:
'=============
Private Sub Worksheet_Activate()
Call MyMacro
End Sub
'<<=============

This is worksheet event code and should be pasted
into the worksheets's code module (not a standard
module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

In a standard module:

Alt-F11 to open the VBE,
Tools | Insert | Module
paste the following
code:
'=============
Public Sub MyMacro()
'Your code, e.g.:
MsgBox Prompt:="Hi!"
End Sub
'<<=============


---
Regards,
Norman


"Trebor Retrac" wrote in message
...
I would like to have a macro execute every time a specific Worksheet is
selected.

Thank You,
Bob carter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default execute macro on Worksheet selection

Thanks Norman, the macro does exactly what i wanted.

Bob Carter
Douglas, MA USA


"Norman Jones" wrote:

Hi Bob

Try:
'=============
Private Sub Worksheet_Activate()
Call MyMacro
End Sub
'<<=============

This is worksheet event code and should be pasted
into the worksheets's code module (not a standard
module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

In a standard module:

Alt-F11 to open the VBE,
Tools | Insert | Module
paste the following
code:
'=============
Public Sub MyMacro()
'Your code, e.g.:
MsgBox Prompt:="Hi!"
End Sub
'<<=============


---
Regards,
Norman


"Trebor Retrac" wrote in message
...
I would like to have a macro execute every time a specific Worksheet is
selected.

Thank You,
Bob carter




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
2Q:Indirect worksheet selection in macro, Calc off for specific sh seed Excel Discussion (Misc queries) 1 December 30th 08 09:11 PM
How to execute a macro in a protected worksheet? Ha Noi Excel Programming 2 April 4th 07 01:38 AM
Worksheet, selection macro Steve Excel Worksheet Functions 5 November 2nd 06 01:26 AM
How to keep ONKey's macro on Worksheet Selection Change Event mikeburg[_21_] Excel Programming 2 September 1st 05 01:59 PM
Record Worksheet Content as Macro and Execute from another Worksheet David McRitchie[_2_] Excel Programming 2 July 23rd 03 09:43 AM


All times are GMT +1. The time now is 09:19 AM.

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"