+ Reply to Thread
Results 1 to 11 of 11

Macro that runs when ran from Macro menu, but stops when using short cut keys...

  1. #1
    Registered User
    Join Date
    09-12-2014
    Location
    Morrisville, NC
    MS-Off Ver
    2013
    Posts
    40

    Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Hello all,

    I'm having an issue with a macro that I cannot seem to figure out why it isn't working properly. If I go to the view macro menu and run it from there, it works just fine, every time. While I was building it, I set a short cut key (Ctrl+Shift+L) to run it. It gets to a certain point and just stops. No error messages, just stops.

    I'm having the macro open another spreadsheet to pull information from. When ran from the menu, it opens the file just fine and continues on with the macro. When ran from the short cut key however, it opens the file then just stops.. Oh, I feel I must mention that once the file is open, it reactivates the main window and continues from there. But as I said, when running from the short cut key, it opens the file and just stops.

    Any idea why this happens?

    Let me know if you need to see the code.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Post your code.

    Please use code tags around code. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting. Highlight your code and click the # icon at the top of your post window.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    09-12-2014
    Location
    Morrisville, NC
    MS-Off Ver
    2013
    Posts
    40

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Please Login or Register  to view this content.
    It stops right after
    Please Login or Register  to view this content.
    I've only copied the beginning section of the code. Let me know if you need all of it.

    Oh, on another note. I've tried moving the "Workbooks.Open" code to a different section of the macro (just before the macro needs the information from the other workbook) and I still get the same result, works fine up to that section, opens the workbook and then just stops, but if I run it from the view macro menu, the entire macro works fine.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Impossible to tell what's going on, from that code. There's a lot of redundant selecting happening...

    Seems very odd that it runs fine when called directly, but not from a keyboard shortcut...

    Have you
    a) made sure that the correct keyboard shortcut is mapped to the correct macro (Macros > select macro > Options)
    b) stepped through the code in the VBE (pressing F8) to check each step in turn?

  5. #5
    Registered User
    Join Date
    09-12-2014
    Location
    Morrisville, NC
    MS-Off Ver
    2013
    Posts
    40

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Yes to both a and b... I agree, very odd that it runs fine directly and not the short cut. It also works fine when stepping through the code using F8, but not when running from the short cut.

    Very odd indeed.

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    All I can suggest is removing the keyboard shortcut, then re-applying it, see if that makes a difference.

  7. #7
    Registered User
    Join Date
    09-12-2014
    Location
    Morrisville, NC
    MS-Off Ver
    2013
    Posts
    40

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Unfortunately no. Even tried a different shortcut key. Same result.

  8. #8
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Hi.

    It might be to do with the fact that holding down the SHIFT key for a certain length of time cancels any Workbook Open event running.

    Romperstomper pointed this out to me when I posted on this forum six months or so back with a similar issue. Was running some long code with a Workbook Open line and then switching to work in other applications whilst it was running, e.g. Word.

    Of course, being a big keyboard user, the SHIFT key is pretty much unavoidable for me. When I realised what was going on, was a nightmare trying to have to come up with workarounds for capital letters, etc.!

    Still, you won't have that issue I guess if you just sort out your shortcut to not include SHIFT. Either that, or don't hold it down for too long!
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  9. #9
    Registered User
    Join Date
    09-12-2014
    Location
    Morrisville, NC
    MS-Off Ver
    2013
    Posts
    40

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    I'll give it a shot...

  10. #10
    Registered User
    Join Date
    09-12-2014
    Location
    Morrisville, NC
    MS-Off Ver
    2013
    Posts
    40

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    Don't ask me why, but that worked. I don't usually hold the shift key down for a long period of time when I activate a macro, but I changed it to a non-shift keyboard shortcut and it worked!

    Really weird!!!

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Macro that runs when ran from Macro menu, but stops when using short cut keys...

    You're welcome!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Timed macro runs for one day, then stops
    By Hardy Eustace in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2013, 01:00 PM
  2. Short code question, macro stops
    By ExcelStarter in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-26-2009, 05:48 PM
  3. Ctrl Shift | Macro Stops | Creating Short Cut Keys
    By gduron in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2006, 06:25 PM
  4. [SOLVED] short cut keys work- run macro does not
    By snax500 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2005, 04:05 PM
  5. [SOLVED] Tracing and reassigning macro short cut keys
    By Graeme in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1