{"id":12174,"date":"2013-06-06T21:47:24","date_gmt":"2013-06-06T21:47:24","guid":{"rendered":"http:\/\/www.learnexcelmacro.com\/?p=2883"},"modified":"2022-08-12T11:43:57","modified_gmt":"2022-08-12T11:43:57","slug":"assign-shortcut-key-to-a-macro","status":"publish","type":"post","link":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/","title":{"rendered":"How to assign a Shortcut key to a Procedure or Subroutine"},"content":{"rendered":"

Dear LEM (Learn Exel Macro) Readers,<\/strong>
\n<\/p>\n

It’s been long time I wrote any article or answered any of your queries. Apologies for the delay in response. I am back with many more amazing articles now. All your un-answered questions will be answered in few days with a set of few interesting articles which will make you awesome in excel VBA \ud83d\ude42
\n
\nSo here is the first article…which will tell you different ways of assigning Shortcut Keys to your code<\/font>
\n<\/p>\n

It always seems magical when you press a key or a combination of keys and the complete code ran in background and you got the end result without clicking on any button on UI (User Interface \/ VBA Form). In this article you will learn the same magic, How to assign a Shortcut Key<\/strong> to a Macro or Subroutine written by you or recorded by you. Mainly there are three ways of doing so and they are very easy to do. First two methods are done from Macro options available in Excel and the last one is done in excel vba code. This 3rd way will be explained in the next article with the proper code and a downloadable example sheet practice on it.<\/p>\n

<\/p>\n

Method 1: <\/h2>\n

Assigning a Short Key while recording a New Macro : <\/font> Follow the below mentioned steps to assign a Short Key to a Macro while recording it.
\n 
\nStep 1.<\/strong>Launch Record Macro Dialog Box as show in the picture below. Click to know how to record a macro<\/a>
\n 
\n\"Assign
\n 
\nStep 2. <\/strong> Enter your Shortcut Key which ever you like it in the Shortcut Key box as highlighted in the above image.
\n 
\nStep 3. <\/strong> Click OK and Stop the recording.
\n 
\nStep 4. <\/strong> Now Press ALT + F11<\/strong> to see the VBA Code window
\n 
\nStep 5. <\/strong> Now Go to the Module to see your Subroutine which is assigned a Shortcut Key as shown in the below picture.
\n 
\n\"Shortcut
\n 
\nStep 6. <\/strong> In the above placeholder you can write your complete code what you want it to do on pressing Shortcut Key assigned.
\nFor example in the Above example, Shortcut Key assigned would be CTRL + p<\/strong>
\n 
\nNote:<\/strong> Shortcut key is case sensitive. <\/font>
\n 
\nLets write one line code inside that module as shown below:
\n <\/p>\n

\r\nSub Macro1()\r\n\r\n' Macro1 Macro\r\n'\r\n' Keyboard Shortcut: Ctrl+p\r\n'\r\nMsgBox \"You have just pressed the Shortcut Key CTRL + P \"\r\nEnd Sub\r\n<\/code><\/pre>\n

 <\/p>\n

Now from the workbook as soon as you press the Shortcut Key CTRL + P<\/strong> message box statement will be executed and one message box will be displayed as shown below:<\/p>\n

Method 2: <\/h2>\n

Assigning a Short Key to an already written Macro or Subroutine : <\/font> Follow the below mentioned steps to assign a Short Key to a Macro which is already written in any module:
\n 
\nStep 1. <\/strong>Go to your Worksheet and Press ALT + F8<\/strong> or go to
Developer Tab<\/a> and click on Macro as shown in below image:
\n <\/p>\n

\"Assign
\n 
\nStep 2. <\/strong>Select Your particular macro or Subroutine from the dropdown and click on Option as shown below:
\n 
\n\"Assign
\n 
\nStep 3. <\/strong>Now Enter your Shortcut Key in the box and click Ok. That particular short cut key is now assigned to the selected subroutine.
\n<\/p>\n

Limitations of assigning a Shortcut Key using Excel option<\/h2>\n

Using excel option as explained above, you can not assign a special Key as Shortcut key for your macro. Special Key means, the keys which can not be typed in the shortcut key box like Backspace, Enter Key, All Function Keys like F1, F2 etc.<\/strong>
\n 
\nThis limitation can be overcome by
assigning a shortcut key using VBA code.<\/a><\/i><\/strong><\/font>
\n <\/p>\n

\nIf you are assigning a shortcut key using excel vba code, then you will be able to assign these special keys as a shortcut key for your macro. Read the Next Article to assign a Shortcut Key using excel vba code. <\/a><\/font><\/a><\/strong><\/p><\/blockquote>\n<\/span>","protected":false},"excerpt":{"rendered":"

Dear LEM (Learn Exel Macro) Readers, It’s been long time I wrote any article or answered any of your queries. Apologies for the delay in response. I am back with many more amazing articles now. All your un-answered questions will be answered in few days with a set of few interesting articles which will make […]<\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[1674,1675,1676],"tags":[],"yoast_head":"\nHow to assign a Shortcut key to a Procedure or Subroutine - Let's excel in Excel<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to assign a Shortcut key to a Procedure or Subroutine\" \/>\n<meta property=\"og:description\" content=\"Dear LEM (Learn Exel Macro) Readers, It’s been long time I wrote any article or answered any of your queries. Apologies for the delay in response. I am back with many more amazing articles now. All your un-answered questions will be answered in few days with a set of few interesting articles which will make […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/\" \/>\n<meta property=\"og:site_name\" content=\"Let's excel in Excel\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:author\" content=\"http:\/\/www.facebook.com\/vmlogger\" \/>\n<meta property=\"article:published_time\" content=\"2013-06-06T21:47:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-08-12T11:43:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/06\/Assign-Short-Key-1.jpg\" \/>\n<meta name=\"author\" content=\"Vishwamitra Mishra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/www.twitter.com\/learnexcelmacro\" \/>\n<meta name=\"twitter:site\" content=\"@learnexcelmacro\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vishwamitra Mishra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/\"},\"author\":{\"name\":\"Vishwamitra Mishra\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"headline\":\"How to assign a Shortcut key to a Procedure or Subroutine\",\"datePublished\":\"2013-06-06T21:47:24+00:00\",\"dateModified\":\"2022-08-12T11:43:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/\"},\"wordCount\":626,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"articleSection\":[\"Excel Macro Basics\",\"Excel Macro Tutorial\",\"Excel Tips\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/\",\"name\":\"How to assign a Shortcut key to a Procedure or Subroutine - Let's excel in Excel\",\"isPartOf\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\"},\"datePublished\":\"2013-06-06T21:47:24+00:00\",\"dateModified\":\"2022-08-12T11:43:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/vmlogger.com\/excel\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Macro Basics\",\"item\":\"https:\/\/vmlogger.com\/excel\/excel-macro-basics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to assign a Shortcut key to a Procedure or Subroutine\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#website\",\"url\":\"https:\/\/vmlogger.com\/excel\/\",\"name\":\"Let's excel in Excel\",\"description\":\"Let's share knowledge\",\"publisher\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/vmlogger.com\/excel\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5\",\"name\":\"Vishwamitra Mishra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"contentUrl\":\"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png\",\"width\":528,\"height\":560,\"caption\":\"Vishwamitra Mishra\"},\"logo\":{\"@id\":\"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/\"},\"description\":\"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.\",\"sameAs\":[\"http:\/\/www.learnexcelmacro.com\",\"http:\/\/www.facebook.com\/vmlogger\",\"https:\/\/twitter.com\/https:\/\/www.twitter.com\/learnexcelmacro\",\"https:\/\/www.youtube.com\/c\/VMLogger\"],\"url\":\"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to assign a Shortcut key to a Procedure or Subroutine - Let's excel in Excel","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/","og_locale":"en_US","og_type":"article","og_title":"How to assign a Shortcut key to a Procedure or Subroutine","og_description":"Dear LEM (Learn Exel Macro) Readers, It’s been long time I wrote any article or answered any of your queries. Apologies for the delay in response. I am back with many more amazing articles now. All your un-answered questions will be answered in few days with a set of few interesting articles which will make […]","og_url":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/","og_site_name":"Let's excel in Excel","article_publisher":"http:\/\/www.facebook.com\/vmlogger","article_author":"http:\/\/www.facebook.com\/vmlogger","article_published_time":"2013-06-06T21:47:24+00:00","article_modified_time":"2022-08-12T11:43:57+00:00","og_image":[{"url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2013\/06\/Assign-Short-Key-1.jpg"}],"author":"Vishwamitra Mishra","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/www.twitter.com\/learnexcelmacro","twitter_site":"@learnexcelmacro","twitter_misc":{"Written by":"Vishwamitra Mishra","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#article","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/"},"author":{"name":"Vishwamitra Mishra","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"headline":"How to assign a Shortcut key to a Procedure or Subroutine","datePublished":"2013-06-06T21:47:24+00:00","dateModified":"2022-08-12T11:43:57+00:00","mainEntityOfPage":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/"},"wordCount":626,"commentCount":3,"publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"articleSection":["Excel Macro Basics","Excel Macro Tutorial","Excel Tips"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/","url":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/","name":"How to assign a Shortcut key to a Procedure or Subroutine - Let's excel in Excel","isPartOf":{"@id":"https:\/\/vmlogger.com\/excel\/#website"},"datePublished":"2013-06-06T21:47:24+00:00","dateModified":"2022-08-12T11:43:57+00:00","breadcrumb":{"@id":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vmlogger.com\/excel\/2013\/06\/assign-shortcut-key-to-a-macro\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vmlogger.com\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Macro Basics","item":"https:\/\/vmlogger.com\/excel\/excel-macro-basics\/"},{"@type":"ListItem","position":3,"name":"How to assign a Shortcut key to a Procedure or Subroutine"}]},{"@type":"WebSite","@id":"https:\/\/vmlogger.com\/excel\/#website","url":"https:\/\/vmlogger.com\/excel\/","name":"Let's excel in Excel","description":"Let's share knowledge","publisher":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vmlogger.com\/excel\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/7500a107b0b2d35a8492acf0d11fc8e5","name":"Vishwamitra Mishra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/","url":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","contentUrl":"https:\/\/vmlogger.com\/excel\/wp-content\/uploads\/sites\/11\/2022\/07\/avataaars-1.png","width":528,"height":560,"caption":"Vishwamitra Mishra"},"logo":{"@id":"https:\/\/vmlogger.com\/excel\/#\/schema\/person\/image\/"},"description":"My name is Vishwamitra Mishra. Friends Call me Vishwa. I hold a Bachelor\u2019s Degree in Computer Science from D.A.V.V. Indore & currently working as a Technical Lead having over 7 years of experience.","sameAs":["http:\/\/www.learnexcelmacro.com","http:\/\/www.facebook.com\/vmlogger","https:\/\/twitter.com\/https:\/\/www.twitter.com\/learnexcelmacro","https:\/\/www.youtube.com\/c\/VMLogger"],"url":"https:\/\/vmlogger.com\/excel\/author\/vishwamitra\/"}]}},"_links":{"self":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12174"}],"collection":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/comments?post=12174"}],"version-history":[{"count":0,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/posts\/12174\/revisions"}],"wp:attachment":[{"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/media?parent=12174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/categories?post=12174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vmlogger.com\/excel\/wp-json\/wp\/v2\/tags?post=12174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}