Results 1 to 3 of 3

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

Threaded View

  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?

    Private Sub Workbook_Open()
        Sheets("ENTRY").Activate
        Application.Goto Reference:="geared_slew"
        Application.OnKey "{ENTER}", "NavigateEntrySheetWithEnterKey" 'Listen for ENTER KEY events
    End Sub
    .
    .
    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?

    Sub Macro1()
        Application.Run "'Std. Data Pack Template (Slew Rings) v02.working.xlsm'!NavigateEntrySheetWithEnterKey"
    End Sub
    .
    .
    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?
    Sub NotGreat()
        Application.Run "'" & ThisWorkbook.name & "'!" & "NavigateEntrySheetWithEnterKey"
    End Sub
    Thanks in advance,
    Michelle
    Last edited by michellepace; 12-05-2017 at 05:21 AM. Reason: orange is okay but not great

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] [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