+ Reply to Thread
Results 1 to 5 of 5

Assigning a macro shortcut key to a symbol

Hybrid View

  1. #1
    Registered User
    Join Date
    03-27-2014
    Location
    NYC
    MS-Off Ver
    Excel 2013
    Posts
    3

    Assigning a macro shortcut key to a symbol

    Hello

    I've searched for a solution to this to no avail. Basically what I would like to do is map the functions increase decimal and decrease decimal to CTRL+Shift+Comma and CTRL+Shift+Period, respectively.

    I have the macros set for these functions, but due to the Excel limitations have mapped them to CTRL+Shift+N and M

    However, out of sheer force of habit due to almost a decade of using plugin from S&P Capital IQ, I keep hitting CTRL+Shift+Comma and Period. Apparently without the plugin, these key combinations are fill down and fill right which have the double effect of managing to delete the number in the cell in addition to not doing the decimal thing I originally wanted.

    I've seen some posts mentioning Application.Onkey but for some reason when I try to use it, it never actually works

    Does anyone have any ideas? It would be very much appreciated. Thank you!



    Here is the current code I'm using

    Sub Increase_Decimal()
    '
    'Increase Decimal Macro
    'Keyboard Shortcut: Ctrl+Shift+N
    '
    Application.CommandBars.FindControl(ID:=398).Execute
    End Sub

    Sub Decrease_Decimal()
    '
    'Decrease Decimal Macro
    'Keyboard Shortcut: Ctrl+Shift+M
    '
    Application.CommandBars.FindControl(ID:=399).Execute
    End Sub

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Assigning a macro shortcut key to a symbol

    Please use Code tags when posting code, not Quote tags. Code tags help to preserve formatting.

    In the ThisWorkbook Module, enter the following code. (If you have multiple workbooks open, check that it is the correct one, there will be a 'ThisWorkbook' module for each workbook that is open.

    Private Sub Workbook_Activate()
        Application.OnKey "+^{<}", "Increase_Decimal"
        Application.OnKey "+^{>}", "Decrease_Decimal"
    End Sub
    
    Private Sub Workbook_Deactivate()
        Application.OnKey "+^{<}"
        Application.OnKey "+^{>}"
    End Sub
    Save your workbook, deactivate the workbook and reactivate it, either by closing it or switching to another one, then back again, your desired shortcuts should now work.

    edit:- the deactivate code is there so that it only runs on the workbook with the code, the shortcut keys will return to normal for other workbooks.
    Last edited by jason.b75; 06-17-2016 at 04:08 PM.

  3. #3
    Registered User
    Join Date
    03-27-2014
    Location
    NYC
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Assigning a macro shortcut key to a symbol

    You are absolutely amazing. Thank you so much

    EDIT - figured out that if I delete the deactivate code it runs on everything which is what I want. Thank you again
    Last edited by redgrenadine; 06-17-2016 at 04:13 PM.

  4. #4
    Registered User
    Join Date
    03-27-2014
    Location
    NYC
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Assigning a macro shortcut key to a symbol

    Actually wait - it doesn't work unless I have the Personal workbook opened as well. Any way to ensure it runs on every workbook when I open excel?

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Assigning a macro shortcut key to a symbol

    A workbook containing the code needs to be open for it to work.

    See if this helps
    https://support.office.com/en-gb/art...ad=GB&fromAR=1

+ 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. [SOLVED] Assigning shortcut Key
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2015, 03:37 AM
  2. Best way to shortcut a symbol while entering data
    By cman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-26-2010, 03:03 PM
  3. Symbol Shortcut
    By swordswinger710 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-08-2008, 11:27 AM
  4. [SOLVED] what shortcut key do I use for the + symbol over the - symbol
    By cherokee in forum Excel General
    Replies: 5
    Last Post: 07-13-2006, 07:45 PM
  5. Assigning values to a symbol
    By Stephen Doyle in forum Excel General
    Replies: 4
    Last Post: 03-23-2006, 06:15 PM
  6. [SOLVED] assign a symbol to a shortcut key
    By Martin Hennegriff in forum Excel General
    Replies: 1
    Last Post: 03-10-2005, 05:06 PM
  7. [SOLVED] Macro shortcutsWhen you are assigning a keyboard shortcut to a macro?
    By JudithJubilee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2005, 04:06 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