Forum Discussion

yugal40's avatar
yugal40
Brass Contributor
Jan 05, 2022

Macro should work in only the file it is written in

Hi Folks,

I have some macro excel files and i have assigned them shortcuts, But when normal files are opened then those macros work on those files instead of default excel shortcuts. for example Ctrl+Shift+L is shortcut for filter but in my macro enabled file i have assigned some macro but while that macro file is opened in my PC then in all the excel files Ctrl+Shift+L works as that macro, But i want that to work in only that workbook not others, Is there a way to do the same?

Thanks

  • Martin_Weiss's avatar
    Martin_Weiss
    Bronze Contributor

    Hi yugal40 

     

    since all worksheets are usually opened within one single instance of Excel, the defined shortcuts are valid for all open worksheets.

     

    You can probably avoid this if you open your macro file in a separate Excel instance. To do so, press the Alt-Key and hold it when you launch Excel, until you get a window like this:

    Now you can release the Alt-Key and click on Yes to start a new instance.

     

    And open all the other files in another Excel instance, not in the same one where the macro file is opened. This way I imagine the shortcuts should work as expected.

     

    • yugal40's avatar
      yugal40
      Brass Contributor
      Thankyou for your reply, Honestly looking for some thing which can normally be used, like many people use those file so every one is not capable of remembering alt key while opening an excel instance.
      • Khalil600's avatar
        Khalil600
        Copper Contributor
        I'm very new to macro, I saved my macro as custom templet and instead of using short cut key I select from the list and run desired macro on the sheet I'm working in, not sure if this will help you or not.

Resources