Run Worksheet_Activate from another workbook

  • Hi all,


    Is it possible to fire Worksheet_Activate event from another workbook? Let's say I have workbook "WB_1" that references sheets in "WB_2" through VBA. On Sheet1 in WB_2 there's some code that gets triggered when the sheet is activated. So, in a perfect world I would want to be able to run the following code in WB_1:




    Only, the ws.Activate piece doesn't trigger the Worksheet_Activate event. Any suggestions?

  • Re: Run Worksheet_Activate from another workbook


    Quote from Derk;728881

    If it's Workbooks("WB_2.xlsx") it won't have any macros to activate.



    That is obviously a typo, and my workbooks are obviously not actually named WB_1 and WB_2. What I would be glad to figure out is how to make Worksheet_Activate event run from a different workbook - anyone had any experience with that?

  • Re: Run Worksheet_Activate from another workbook


    I'm surprised the activate command doesn't fire when the sheet is activated. It may be that the sheet you are activating is already the active sheet when wb2 is activated. If that is the case, activate some other sheet in wb2 and then activate the one you want. (I tested this and it works for me.) However, in WB2 you could have the activate code do nothing but call a macro in a general module (with the code that you want to have happen when the sheet is activated. Then in wb 1, call the general module routine after the sheet is activated.

  • Re: Run Worksheet_Activate from another workbook


    Thanks Derk, you're absolutely right - the first part of my issue was caused by the fact that I open WB2 using VBA in WB1. Thus, since the first sheet that's activated when I open WB2 is one of the tabs where Worksheet_Activate should run, the event doesn't get triggered. I'm still trying to figure out why the heck it would not run on other sheets correctly, but that's a step in the right direction!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!