+ Reply to Thread
Results 1 to 9 of 9

Run Macro on Enter Key

  1. #1
    Registered User
    Join Date
    12-17-2014
    Location
    Perth, Australia
    MS-Off Ver
    Windows 7
    Posts
    85

    Run Macro on Enter Key

    In ThisWorkbook I have the below:

    Please Login or Register  to view this content.
    And in Module 1 I have the below:

    Please Login or Register  to view this content.
    This was code provided to me a little while back now and I couldn't ever get it to work, nothing happens when I press enter??? Is it a setting in excel for it not working or is the code wrong? I've attached the workbook.
    Attached Files Attached Files

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Run Macro on Enter Key

    Hmm odd, it works on my end.
    you could try moving the workbook_open macro to module 1 with your myMacro sub. Rename workbook_open to auto_open and try that.

    Edit: I did have to save your file, enable editing, allow macros, close and open again. But after that it works each time I open it.
    Last edited by Arkadi; 01-09-2015 at 02:20 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    12-17-2014
    Location
    Perth, Australia
    MS-Off Ver
    Windows 7
    Posts
    85

    Re: Run Macro on Enter Key

    Hi Arkadi,

    Still didn't work. I'm just clicking in a cell then pressing enter, should it work from doing that? Also typing random text in a cell and then pressing enter and nothing happens.

    Been online and the examples are all very similar, which is why I think it might be an excel setting problem, but I don't know where to look.

    I have no idea why it's not working for me.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Run Macro on Enter Key

    Yes what you are doing works when I try, in a cell, on a cell, with or without text. Go to the workbook_open macro, and press F8 to step through it. That way you know that at least manually, it ran. Then try to go back to the sheet and try Enter again... any difference? I am trying to establish if it is that the open macro is not running, or if it is that it just doesn't work.

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Run Macro on Enter Key

    By the way, just realized it only works with the numpad enter key for me. Did you try that enter key?

    The code is different for "main" enter key, so if you want both detected, try this:

    Please Login or Register  to view this content.
    Last edited by Arkadi; 01-09-2015 at 02:27 PM.

  6. #6
    Registered User
    Join Date
    12-17-2014
    Location
    Perth, Australia
    MS-Off Ver
    Windows 7
    Posts
    85

    Re: Run Macro on Enter Key

    Oh, didn't try the numpad, but that works.

    Is something else typed when using the main enter key? If not, I should be able to get by with the numpad enter key.

    Thanks

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Run Macro on Enter Key

    See my edit on my last post for the other enter key.

  8. #8
    Registered User
    Join Date
    12-17-2014
    Location
    Perth, Australia
    MS-Off Ver
    Windows 7
    Posts
    85

    Re: Run Macro on Enter Key

    LEGEND!!! Works a treat. Thanks heaps.

  9. #9
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Run Macro on Enter Key

    Glad I could help Jeckford
    Thanks for the rep!

+ 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. Alt + enter macro
    By boss1982 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-16-2013, 12:23 PM
  2. Run Macro by Pressing Enter Key
    By styre in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2009, 03:49 PM
  3. Pause macro to enter value, continue macro
    By DamienC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2008, 09:01 AM
  4. Macro to enter a shape with text and macro
    By RAH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-07-2008, 10:16 PM
  5. Unable to enter sum as a macro
    By music43 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-18-2005, 10:01 AM

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