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!
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