Worksheet_Activate

  • Thread starter Thread starter Pozzo
  • Start date Start date
P

Pozzo

I have declared a subroutine:

Private Sub Worksheet_Activate()

with the belief that this is executed when the sheet or workbook opens
However, when I have closed the workbook and re-opened, the code ha
not been executed. I have put Debug.Print statements at the beginnin
and end but Excel doesn't even enter this code. Are there an
circumstances under which this might happen
 
Did you do this in the sheet code module or a general module?
It must be in the sheet's module.
 
I need to have this code run specifically for this sheet, though, so
can't attach it to a workbook event.

I've just found out that the code executes when a move away to anothe
sheet and then come back, just not when the workbook opens with thi
sheet as the active sheet. Is this how it is supposed to work
 
The ThisWorkbook event only activates a macro it doesn't restrict the scope of the macro (i.e. you can use it to activate a macro to run formulas on sheet1)

Yes it will activate if you unselect the sheet and re-select it. That's how it is supposed to work. If you need to run when open the workbook you need the "ThisWorkbook_Open()" event. You could go to another sheet and save it. When you open the workbook again you would be forced to select that sheet again, hence, activate the event (I don't recommend that)

----- Pozzo > wrote: ----

I need to have this code run specifically for this sheet, though, so
can't attach it to a workbook event

I've just found out that the code executes when a move away to anothe
sheet and then come back, just not when the workbook opens with thi
sheet as the active sheet. Is this how it is supposed to work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top