ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   On activate event (https://www.excelbanter.com/excel-programming/349195-activate-event.html)

SHIPP

On activate event
 
I want to run a procedure when a user clicks on a worksheet. The code should
be something like

Private Sub workbook_SheetActivate(ByVal Sh As Object)
MsgBox Sh.Name
End Sub

I've tried putting this in a module and underneath the sheets to no avail.
Where should I put this code if I want it to run when a worksheet is clicked
and active?
--
M. Shipp

Norman Jones

On activate event
 


--
---
Regards,
Norman



"SHIPP" wrote in message
...
I want to run a procedure when a user clicks on a worksheet. The code
should
be something like

Private Sub workbook_SheetActivate(ByVal Sh As Object)
MsgBox Sh.Name
End Sub

I've tried putting this in a module and underneath the sheets to no avail.
Where should I put this code if I want it to run when a worksheet is
clicked
and active?
--
M. Shipp




K Dales[_2_]

On activate event
 
In ThisWorkbook (since it is a workbook event)
--
- K Dales


"SHIPP" wrote:

I want to run a procedure when a user clicks on a worksheet. The code should
be something like

Private Sub workbook_SheetActivate(ByVal Sh As Object)
MsgBox Sh.Name
End Sub

I've tried putting this in a module and underneath the sheets to no avail.
Where should I put this code if I want it to run when a worksheet is clicked
and active?
--
M. Shipp


Dave Peterson

On activate event
 
Since you're using the Workbook_ version, put it under ThisWorkbook.


SHIPP wrote:

I want to run a procedure when a user clicks on a worksheet. The code should
be something like

Private Sub workbook_SheetActivate(ByVal Sh As Object)
MsgBox Sh.Name
End Sub

I've tried putting this in a module and underneath the sheets to no avail.
Where should I put this code if I want it to run when a worksheet is clicked
and active?
--
M. Shipp


--

Dave Peterson

Norman Jones

On activate event
 
Hi SHIPP,

You need to move the code to the ThisWorkbook module.


---
Regards,
Norman



"SHIPP" wrote in message
...
I want to run a procedure when a user clicks on a worksheet. The code
should
be something like

Private Sub workbook_SheetActivate(ByVal Sh As Object)
MsgBox Sh.Name
End Sub

I've tried putting this in a module and underneath the sheets to no avail.
Where should I put this code if I want it to run when a worksheet is
clicked
and active?
--
M. Shipp




Tom Ogilvy

On activate event
 
You have received several answers, but
For more information on events

http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy


"SHIPP" wrote in message
...
I want to run a procedure when a user clicks on a worksheet. The code

should
be something like

Private Sub workbook_SheetActivate(ByVal Sh As Object)
MsgBox Sh.Name
End Sub

I've tried putting this in a module and underneath the sheets to no avail.
Where should I put this code if I want it to run when a worksheet is

clicked
and active?
--
M. Shipp





All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com