+ Reply to Thread
Results 1 to 3 of 3

How to simulate the ENTER KEY being pressed (ie trigger Enter Key event)

  1. #1
    Forum Contributor michellepace's Avatar
    Join Date
    10-28-2015
    Location
    South Africa
    MS-Off Ver
    2013
    Posts
    132

    Question How to simulate the ENTER KEY being pressed (ie trigger Enter Key event)

    Hi there,

    I have defined an event listener for the ENTER KEY as shown in the code below. Instead of relying on my user to hit the enter key, I want to "simulate" or "trigger" the enter key being pressed in VBA code. Does anyone know how to do this?

    Please Login or Register  to view this content.
    .
    .
    I attempted to find out for myself by recording a macro whilst hitting the enter key. What I don't like about using "" is that it hardcodes both the name of my excel workbook as well as the name of my Sub. Is there a better way?

    Please Login or Register  to view this content.
    .
    .
    The best or "cleanest" I can fathom is the code below... but still, surely there is a simple way to just "fire the enter key" being pressed?
    Please Login or Register  to view this content.
    Thanks in advance,
    Michelle
    Last edited by michellepace; 12-05-2017 at 05:21 AM. Reason: orange is okay but not great

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: How to simulate the ENTER KEY being pressed (ie trigger Enter Key event)

    .
    https://stackoverflow.com/questions/...ell-in-vba-for

    https://msdn.microsoft.com/en-us/vba...y-method-excel

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: How to simulate the ENTER KEY being pressed (ie trigger Enter Key event)

    When it comes to simulating the press of the "enter" button, then try "SendKeys" statement.
    SendKeys Statement - sends one or more keystrokes to the active window as if typed at the keyboard.
    Please Login or Register  to view this content.

+ 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. Run a macro when Enter or Tab key is pressed
    By anandvh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-18-2017, 10:54 PM
  2. Run macro when the enter key (only) is pressed
    By Jeckford in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-17-2014, 02:06 PM
  3. [SOLVED] Return alt-enter when enter is pressed in a specific cell
    By bigsteve in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-17-2013, 10:21 AM
  4. Simulate enter key on Mac Powerbook
    By capngene in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2012, 10:53 PM
  5. do something when enter is pressed
    By TechRetard in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-11-2011, 05:24 PM
  6. VBA to simulate the enter button?
    By Bob O in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-15-2005, 01:05 PM
  7. [SOLVED] simulate a enter key behaviour?
    By Liedson31 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2005, 10:05 AM

Tags for this Thread

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