Is there a way to make a macro run when I click on a specific worksheet?
D Dave Peterson Jul 6, 2005 #2 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
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