+ Reply to Thread
Results 1 to 5 of 5

Application.OnKey key codes

  1. #1
    Valued Forum Contributor ffffloyd's Avatar
    Join Date
    05-20-2008
    Location
    Melbourne, VIC, Australia
    MS-Off Ver
    Office 365
    Posts
    243

    Application.OnKey key codes

    The Excel Help file lists a number of codes that can be used to describe keys for use with Application.OnKey, but what are the codes for naming the numeric keypad keys?

    I have tried the digits alone but they describe the numbers above the QWERTY row and specifically work only with them; not the numeric keypad. I want to do the opposite.

    I have tried enclosing the digits in braces, eg "^{2}" for ctrl-2 but that doesn't do the trick either.

    There must surely be codes for them but the Help appears to omit them.

    What I really want to do is attach them to macros, because Excel itself only lets you stipulate letters. You can customise Word with pretty well anything on the keyboard. I think we should be able to do the same with Excel.
    Last edited by ffffloyd; 08-15-2011 at 09:29 AM.

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Application.OnKey key codes

    Hi,

    This worked fine for me to make CTRL+1 shortcut:

    Please Login or Register  to view this content.
    I'd never use CTRL+1 as a procedure caller though, because it's an important shortcut to the format cells dialog.
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Valued Forum Contributor ffffloyd's Avatar
    Join Date
    05-20-2008
    Location
    Melbourne, VIC, Australia
    MS-Off Ver
    Office 365
    Posts
    243

    Re: Application.OnKey key codes

    Thanks Colin. That activates only the 1 above the QWERTY line though and, as you say, would override the existing functionality. That's why I am wanting to designate the numeric keypad. Do you know of codes that will specify the 1 on the numeric keypad and not interfere with the row of numbers on the QWERTY keyboard?

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Application.OnKey key codes

    Sure, assuming numlock is on, CTRL+1 (numeric keypad) would be:

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor ffffloyd's Avatar
    Join Date
    05-20-2008
    Location
    Melbourne, VIC, Australia
    MS-Off Ver
    Office 365
    Posts
    243

    Re: Application.OnKey key codes

    Excellent. That works, and I see it works for the rest of the keypad if you extend the sequence too (eg, 2 is {98}, 3 is {99} etc.)

    So conceivably, you can use the key number of any key on the keyboard in braces to represent that key?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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