PDA

View Full Version : macro shortcut runs on other workbook



wilg
05-27-2011, 06:43 PM
Hi guys, I have a macro shortcut...

Ctrl+Shift x that is in 2 separate workbooks.

If I have both workbooks open the macro runs on both workbooks. I want to know if I can set it for just the active workbook..

Aussiebear
05-28-2011, 12:59 AM
Every possibility, but since we don't yet see your code...... we are only guessing

GTO
05-28-2011, 01:54 AM
Hi All,

Not tested, but as .Onkey applies to the Application, I believe whatever was last assigned is what will happen in that instance of the Application.

I would try using each Workbook's Activate and Deactivate events. In the Activate event, set .OnKey to whatever code you want to run in that workbook. In the Deactivate event, have .OnKey revert to whatever Excel normally does. This way, the key combo is only in efffect when you want it to be.

Have a great weekend!

Mark