Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to activate "Worksheet_activate" event? 2

Status
Not open for further replies.

sjh

Programmer
Oct 29, 2001
263
US
Hi,

I defined the following procedure in one of my worksheet.
Private Sub worksheet_activate()

But it doesn't seem to fire when I activate the worksheet by clicking on the tab or I execute this statement.

Sheets("myworksheet").Activate

What am I doing wrong?

Please help,
SJH
 

If your sub "Private Sub worksheet_activate()" is on the code page for the "myworksheet" worksheet it should work just fine. (It does for me. Right-click on the "myworksheet" worksheet tab and select "View Code") Where did you put the sub?

 
Yes, I put my worksheet_activate() in the "myworksheet" code page. I put a breakpoint on the "Private Sub worksheet_activate()" but it does not break!

SJH :(
 
sjh,

The best way to get to the CORRECT code page is to right click on the SHEET TAB. This will display the CODE PAGE for the Worksheet in question.

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
I still have the problem..

I even created a brand new Excel workbook and added two simple codes.

In Sheet 1, I have:
Private Sub CommandButton1_Click()
Sheets("Sheet2").Activate
End Sub
__________________________________________
In Sheet2:
Private Sub Worksheet_Activate()
MsgBox "Sheet2"
End Sub

And Worksheet_Activate() for Sheet2 never gets fired. Is there a different way to accomplish the same goal?

Thank you!
SJH
 
Tools > Macros > Security

Set it to medium or low, whichever one doesn't automatically disable macros.

*cLFlaVA
----------------------------
When will I be able to see what other members can see about myself? It's been like, a freakin' month already!
 
sjh
I'm just wondering, have events been disabled at some point? Do other events work?

Try running this code once, from any module
Sub EnableEvents()
Application.EnableEvents = True
End Sub

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Thanks Loomah!

Your suggestion worked!
I guess once the events are disabled in one workbook, it affects the other ones that are created/opened afterwards.

Thanks again!
SJH
 
good tip -

If we knew what they meant and browsed them all the VB help while typing would suggest these things but it is a huge task to look, interpret and test the long list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top