#1   Report Post  
Cheryl
 
Posts: n/a
Default Macro run

Is there a way to make a macro run when I click on a specific worksheet?
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

You can tap into the worksheet_activate event.

Rightclick on the worksheet tab that should have this behavior. Select view
code and paste this in:

Option Explicit
Private Sub Worksheet_Activate()
MsgBox "Hi there from: " & Me.Name
End Sub

Now whenever you swap from a different worksheet in the same workbook to this
worksheet, you'll get a message saying "hi".

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

You can read more about events at:
Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm

Cheryl wrote:

Is there a way to make a macro run when I click on a specific worksheet?


--

Dave Peterson
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
Formula for current month minus one = Quarter number in a macro. Pank Excel Discussion (Misc queries) 11 June 22nd 05 03:47 PM
Help with macro looping and color query function kevinm Excel Discussion (Misc queries) 10 May 26th 05 02:25 AM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 11:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 01:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 05:46 PM


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