Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-2023, 05:00 AM
soroush.kalantari soroush.kalantari is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2016
Competent Performer
Is it possible to use keys like ALT for assigning shortcut key to macros in Excel?
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default Is it possible to use keys like ALT for assigning shortcut key to macros in Excel?

I want to use keys like ALT and … for assigning shortcut key to macros in Excel by utilizing onkey command. (for example, I have used this line: Application.OnKey "+%{R}", "copyMRial". But it dose not work for me. (the code show no “run time” error. But when I press the shortcut to run the macro, nothing happens).
Reply With Quote
  #2  
Old 10-30-2023, 11:00 AM
Logit Logit is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Here are assignments related to the ALT key :

6. ALT + Function Keys Shortcut
Shortcut Key Action
Alt+F1 Insert Chart (Creates a chart of the data in the current range)
Alt+F2 Save As
Alt+F4 Closes all workbooks & Exits Excel
Alt+F8 Macro dialog box
Alt+F11 Displays Visual Basic Editor
7. ALT + SHIFT + Function Keys Shortcut
Shortcut Key Action
alt+shft+1 Inserts a new worksheet into the active workbook
Alt+Shft+F2 Displays the Save As dialog box
Alt+Shft+F4 Closes all the workbooks and exits Excel
Alt+Shft+F10 Displays the drop-down menu for the corresponding smart tag
Alt+Shft+F11 Displays the drop-down menu for the corresponding smart tag
8. ALT + Letter Keys Shortcut
Shortcut Key Action
Alt + A + E Convert Text to Columns Wizard
Alt + A + H Hide grouped columns or rows
Alt + A + J Show grouped columns or rows
Alt + A + M Displays the Remove Duplicates dialog box
Alt + A + Q Advanced Filter
Alt + A + SA Sort smallest to largest
Alt + A + SD Sort largest to smallest
Alt + A + SS Displays the Sort dialog box
Alt + B Add or Remove the bottom border
Alt + D Add or Remove the downward diagonal border
Alt + F Go to Backstage View
Alt + H Add or Remove the horizontal interior border
Alt + H + AB Align text to the bottom of the cell
Alt + H + AC Align text to the center of the cell
Alt + H + AL Align text to the left of the cell
Alt + H + AM Align text to the middle of the cell
Alt + H + AN Choose accounting format
Alt + H + AR Align text to the right of the cell
Alt + H + AT Align text to the top of the cell
Alt + H + B Expand Borders drop-down menu
Alt + H + FC Choose font color
Alt + H + FC Expand Font Color drop-down menu
Alt + H + FF Change the font face
Alt + H + FG Increase the font size by 1 point
Alt + H + FK Decrease the font size by 1 point
Alt + H + FM Format Cells dialog box with the Number tab selected
Alt + H + FN Format Cells dialog box with the Font tab selected
Alt + H + FO Clipboard task pane
Alt + H + FP Activates Format Painter
Alt + H + FS Change the font size
Alt + H + H Expand the Fill Color drop-down menu
Alt + H + J Expand the Cell Styles menu
Alt + H + K Format number with a thousand’s comma (,) separator
Alt + H + N Choose number format
Alt + H + T Expand Format as Table drop-down menu
Alt + H + T Expand the Format as Table menu
Alt + H + W Wrap text
Alt + JA Go to the Layout tab of the Ribbon
Alt + JC Go to the Design tab of the Ribbon
Alt + JC + A Expand Add Chart Element drop-down menu
Alt + L Add/ Remove the left border
Alt + L + I Expand the Insert Form Controls and ActiveX Controls drop-down menu
Alt + M + D Trace Dependents
Alt + M + P Trace Precedents
Alt + N + B Insert Bar Chart
Alt + N + C Insert Column Chart
Alt + N + N Insert Line Chart
Alt + N + Q Insert Pie or Doughnut Chart
Alt + N + R Recommended Charts
Alt + N + SD Insert Combo Chart
Alt + N + V Pivot Table
Alt + N + X Insert Text Box
Alt + R Add or Remove the right border
Alt + R + A Show all comments
Alt + R + D Delete comment
Alt + T Add or Remove the top border
Alt + T + O Display Excel Options dialog box
Alt + V Add or Remove the vertical interior border
Alt + W + I Page Break Preview
Alt + W + L Normal View
Alt + W + Q Zoom dialog box
Alt + W + VG View or hide gridlines
Reply With Quote
  #3  
Old 10-30-2023, 09:08 PM
soroush.kalantari soroush.kalantari is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2016
Competent Performer
Is it possible to use keys like ALT for assigning shortcut key to macros in Excel?
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default

Thank you for your reply which I learn from it some useful shortcut keys.I think I have failed to bring up the issue in a clear manner.
Assume I have created a macro with the name "x” and I want to assign a keyboard shortcut to it (by using Onkey command or manually. see this link) . My question is: can the Alt key be used in the combination of keys which are to be assigned to” X”?
Broadly speaking, I am interested about combination of keys which can be used for assigning shortcut keys to macros.
Reply With Quote
  #4  
Old 10-31-2023, 02:05 AM
Logit Logit is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Further research indicates you can not use the ALT key because it is already assigned to the Menu bar at the top of the workbook. This is something that Microsoft predetermined when creating Excel.
Reply With Quote
  #5  
Old 11-01-2023, 06:08 AM
kilroyscarnival kilroyscarnival is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2021
Expert
 
Join Date: May 2019
Posts: 345
kilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nicekilroyscarnival is just really nice
Default

If you have the Developer tab showing on your ribbon, you should be able to look at your list of Macros with the Macro button near the far left. Under there is a button labeled 'Options...' and it allows you to add a shortcut key combination. It's not ALT but it's CONTROL + SHIFT + [letter]. For example, I use CTRL+SHIFT+A to run my address lookup. I do that for some, and for others I make custom buttons on the Quick Access Toolbar.
Reply With Quote
  #6  
Old 11-03-2023, 09:05 PM
soroush.kalantari soroush.kalantari is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2016
Competent Performer
Is it possible to use keys like ALT for assigning shortcut key to macros in Excel?
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default

Thank you for your guidance. I also use your methods, But the number of my macros is very much and because of this, I am considering new methods to make the process of their running more efficient.
Reply With Quote
  #7  
Old 11-05-2023, 08:55 PM
Guessed's Avatar
Guessed Guessed is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Yes it is possible but you will need to run a line of vba code to create the keyboard shortcut.

See this page and video...
2 Ways to Assign Keyboard Shortcuts to Macros - Excel Campus
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #8  
Old 11-06-2023, 10:16 PM
soroush.kalantari soroush.kalantari is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2016
Competent Performer
Is it possible to use keys like ALT for assigning shortcut key to macros in Excel?
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default

As I told before, I have used the Onkey command mentioned in your link (for example, Application.OnKey "+%{R}", "macro name"). , but it doesn’t work although It doesn’t result in any runtime error. It seems The Alt key work for Word macro but not for Excel macro and user is left with just one option Ctr+shift+(key) which is limiting if you want to assign meaningful short cut to a large number of macro.(using Ctr +(key) has the risk of overwriting Excel own shortcut key. Even the short cut is not case-sensitive)
Reply With Quote
  #9  
Old 12-23-2023, 09:18 PM
soroush.kalantari soroush.kalantari is offline Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Windows 10 Is it possible to use keys like ALT for assigning shortcut key to macros in Excel? Office 2021
Competent Performer
Is it possible to use keys like ALT for assigning shortcut key to macros in Excel?
 
Join Date: Jun 2021
Posts: 115
soroush.kalantari is on a distinguished road
Default

I have found the correct answer and have changed my mind: Yes it is possible to use ALT key for assigning shortcuts to macros. The point is the line “+%{R}” must be changed to “^%R”. (see the “Table of Shortcut Key Combinations for Application.OnKey method” section of this link)
Reply With Quote
Reply

Tags
onkey, shortcut



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using shortcut keys 14spar15 Excel 3 09-14-2020 11:00 PM
Assigning shortcut keys via a macro file alex100 Word VBA 6 06-26-2020 09:27 AM
Shortcut keys in Find&Replace fsdance Word 0 02-11-2011 03:27 PM
cant use shortcut keys (ctrl+c/v/z...) laro Office 0 10-08-2010 11:01 PM
Can't Assign Shortcut Keys Vicki F. Word 0 04-17-2010 03:03 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft