Deactivate event not firing

Joined
May 4, 2010
Messages
4
Reaction score
0
I am trying to refresh all pivot tables when a sheet is deactivated but it does not fire at all, ever. If I run the simple macro it works but not when I leave the sheet and go to another sheet. I have placed the code on the sheet, and to test, added a MsgBox but it just simply does not fire.
After reading many posts, I commented out all occurrences of enableEvents = false even though they were all paired with an enableEvents = true at the end of the macro - used the find feature to find all within the project. I have saved, closed and opened again
Still no luck.
Here is the code as it stands - it seems pretty harmless - but I am just learning code and cannot find anything anywhere that discussed causes for a deactivate code to not work. Any and all suggestions are welcome. I did try on a new excel workbook but I didn't get the message box there either - so clearly I am doing something wrong, and it is probably real obvious:)
Thanks in advance!

Code:
Private Sub Worksheet_Deactivate()

Application.EnableEvents = True
ThisWorkbook.RefreshAll
MsgBox "this sheet was deactivated"

End Sub
 
Joined
May 4, 2010
Messages
4
Reaction score
0
Hi all
Since it seemed an excel wide problem, in desperation I shut down excel and started up again, and things seem to be working correctly. Just thought I would post this as a possible "solution" in case someone else is having the same problems. Closing and opening the workbook did not solve the problem, only closing down excel.
Cheers
V
 

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

Top