+ Reply to Thread
Results 1 to 10 of 10

Bind 1 or more keystroke to 1 or more macro's

  1. #1
    Registered User
    Join Date
    09-10-2014
    Location
    Netherlands
    MS-Off Ver
    2007 on Win 7
    Posts
    50

    Bind 1 or more keystroke to 1 or more macro's

    Hi all out there.

    I have a VBA code in my worksheet which binds a key stroke to a macro :

    Please Login or Register  to view this content.
    This code binds CNTRL-s to the macro "SELECTIEBLAD".
    I would like to use CNTRL-SHIFT-s for this macro.
    How do I change the code so that it's not CNTRL-s but CNTRL-SHIFT-s ?

    Furthermore I would like to ask how I can use this code to bind more keystrokes to more macro's,

    such as CNTRL-SHIFT-v for the macro "VOORBLAD"
    and CNTRL-SHIFT-o for the macro "OFFICES"
    and CNTRL-SHIFT-c for the macro "CLIENTS".

    I have tried some changes which I thought where good, but it keeps me giving debugging errors.

    It would be greatfull if somebody could help me with this.

  2. #2
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: Bind 1 or more keystroke to 1 or more macro's

    Have you tried, editing the macro options.

    Go to View -->Macros -->View Macros ...
    Highlight your macro , then click on Options, you will get a dialog box with options shortkey .... it will show your current shortcut if any... you can just change what ever your want....
    By Default you will see Ctrl + [] to select , Here you can Hold Shift on keyboard and enter the letter you want to set to Macro...

    That's it..

  3. #3
    Registered User
    Join Date
    09-10-2014
    Location
    Netherlands
    MS-Off Ver
    2007 on Win 7
    Posts
    50

    Re: Bind 1 or more keystroke to 1 or more macro's

    Hi naveenmarapaka.

    Thanks for your idea, but as the macro's are all private, they are not visible in the way you suggest and therefore not accessable via normal keystrokes.

    Therefore I have to use this code to bind keystrokes to (private) macro.

    So your idea is unfortunately not an option.
    Last edited by mbdigital; 11-19-2014 at 07:45 AM.

  4. #4
    Forum Contributor
    Join Date
    09-05-2012
    Location
    Dubai
    MS-Off Ver
    Office 365
    Posts
    409

    Re: Bind 1 or more keystroke to 1 or more macro's

    Hi,
    Code is not required to assign to macro....
    Try to put Developer Tab in your menu options of excel ( File ->Options ->Customize Ribbon ->select developer on right menu options).. then try above method... if you are not able to view it...

    Note : Do not try to assign a Predefined Keystroke to a macro as it will override the normal behavior
    Example : ^S Normal behavior is to save in excel ..

  5. #5
    Registered User
    Join Date
    09-10-2014
    Location
    Netherlands
    MS-Off Ver
    2007 on Win 7
    Posts
    50

    Re: Bind 1 or more keystroke to 1 or more macro's

    Hi. Remember that private macro's can not be called by keystrokes.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,289

    Re: Bind 1 or more keystroke to 1 or more macro's

    It's:
    "+^S"
    for Ctrl+Shift+S

    Just repeat the OnKey for your other key/macro combinations.
    Remember what the dormouse said
    Feed your head

  7. #7
    Registered User
    Join Date
    09-10-2014
    Location
    Netherlands
    MS-Off Ver
    2007 on Win 7
    Posts
    50

    Re: Bind 1 or more keystroke to 1 or more macro's

    Hi Rory.

    Thanks for your reply.
    This is what I was looking for but how do I seperate the several onkeys?

    Please Login or Register  to view this content.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,289

    Re: Bind 1 or more keystroke to 1 or more macro's

    You need multiple OnKey statements:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-10-2014
    Location
    Netherlands
    MS-Off Ver
    2007 on Win 7
    Posts
    50

    Re: Bind 1 or more keystroke to 1 or more macro's

    Hey Rory ....

    This works perfect !!!

    Thanks a lot for your clear and fine help.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,289

    Re: Bind 1 or more keystroke to 1 or more macro's

    Glad to help.

+ 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. Macro to password protect a workbook and lock and unlock it with a keystroke command
    By justdeepee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2014, 07:00 PM
  2. Macro Keystroke not working
    By Chax in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-23-2012, 05:35 PM
  3. Need a new keystroke or macro that will do the same
    By Elleira2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2012, 04:47 PM
  4. Excel 2007 : Macro, repeat keystroke
    By Graydoggy in forum Excel General
    Replies: 4
    Last Post: 12-06-2009, 09:27 AM
  5. Keystroke Macro
    By Winstern in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2006, 02:12 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