ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If statement syntax to see if Worksheet_Activate code exists (https://www.excelbanter.com/excel-programming/347234-if-statement-syntax-see-if-worksheet_activate-code-exists.html)

mikeburg[_55_]

If statement syntax to see if Worksheet_Activate code exists
 

Need syntax for If statement to see if Worksheet_Activate code exists.

For example

If Sheet1.Worksheet_Activate = True Then

Help please. Thank you. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=490438


Leith Ross[_351_]

If statement syntax to see if Worksheet_Activate code exists
 

Hello Mike,

Worksheet_Activate() is an event handler that exists for all
Worksheets. To place code into this event, open the VBA editor by
pressing ALT and F8. Activate the Project Explorer window by pressing
ALT and R. Click on the sheet where you want to place your code. On
your right is a the code window. At the top of the window you will see
to drop down boxes. The left will say *(General)* and the other
*(Declarations)*. Click on (General) and you will see *Worksheet*
listed. Click on Worksheet. The other drop down will now show
*Selection Change*. This is the default event. Click on the arrow of
this drop down to see all the events for the worksheet. They are listed
alphbetatically. At the top is *Activate*. Click on this and the
following will appear in the code window...

Private Sub Worksheet_Activate()

End Sub

In between Sub and End Sub you can add BEEP. This will generate an tone
whenever the worksheet is activated. Each worksheet has it's own event
handler.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=490438


kounoike

If statement syntax to see if Worksheet_Activate code exists
 
i'm not sure if this is what you are looking for, but how about this?

Sub findproctest()
Dim oCodeM As Object
Dim iStart As Long

For Each oCodeM In ThisWorkbook.VBProject.VBComponents
With oCodeM.codemodule
On Error Resume Next
iStart = 0
iStart = .ProcStartLine("worksheet_activate", vbext_pk_Proc)
If iStart < 0 Then
MsgBox "Worksheet_Activate() found in " & oCodeM.Name
End If
End With
Next
End Sub

keizi

"mikeburg" wrote in
message ...

Need syntax for If statement to see if Worksheet_Activate code exists.

For example

If Sheet1.Worksheet_Activate = True Then

Help please. Thank you. mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile:

http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=490438




All times are GMT +1. The time now is 05:17 PM.

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