Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default shortcut keys

How do you assign a macro to a shortcut key other than a combination
of ctrl that excel allows you to do from the toolsmacrooptions
screen? For example, what if i want to use Alt + 1, or Shift + Ctrl +
1, or Alt + Shift + 1?

Thanks!

J
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default shortcut keys


You can assign Shift+Ctrl+letter manually the same way as Ctrl+letter. It's
simply the same but with the capital. You can also use
Application.MacroOptions, see help. (can also export the bas module to text
file, add the shortcut, and re-import).

If you want to include Alt + letter w/out any combination of Shift+Ctrl you
need to use the OnKey method, again see help for example. You will need to
run the OnKey code each time your macro project loads.

Regards,
Peter T

"cass calculator" wrote in message
...
How do you assign a macro to a shortcut key other than a combination
of ctrl that excel allows you to do from the toolsmacrooptions
screen? For example, what if i want to use Alt + 1, or Shift + Ctrl +
1, or Alt + Shift + 1?

Thanks!

J



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default shortcut keys


OnKey allows many more key combinations
--
Gary''s Student - gsnu200819


"cass calculator" wrote:

How do you assign a macro to a shortcut key other than a combination
of ctrl that excel allows you to do from the toolsmacrooptions
screen? For example, what if i want to use Alt + 1, or Shift + Ctrl +
1, or Alt + Shift + 1?

Thanks!

J

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default shortcut keys

On Dec 9, 3:48*pm, Gary''s Student
wrote:
OnKey allows many more key combinations
--
Gary''s Student - gsnu200819

"cass calculator" wrote:
How do you assign a macro to a shortcut key other than a combination
of ctrl that excel allows you to do from the toolsmacrooptions
screen? For example, what if i want to use Alt + 1, or Shift + Ctrl +
1, or Alt + Shift + 1?


Thanks!


J


Could you please show me a simple example for how to use the OnKey
method for combinations of ctrl, shift and alt?

Thanks,

Joshua
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default shortcut keys

Type onkey into the help diaolog when in the VBE

All combos are listed with usage instructions and examples


Gord Dibben MS Excel MVP

On Wed, 10 Dec 2008 07:50:57 -0800 (PST), cass calculator
wrote:

Could you please show me a simple example for how to use the OnKey
method for combinations of ctrl, shift and alt?

Thanks,

Joshua




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default shortcut keys

On Dec 10, 1:03*pm, Gord Dibben <gorddibbATshawDOTca wrote:
Type onkey into the help diaolog when in the VBE

All combos are listed with usage instructions and examples

Gord Dibben *MS Excel MVP

On Wed, 10 Dec 2008 07:50:57 -0800 (PST), cass calculator

wrote:
Could you please show me a simple example for how to use the OnKey
method for combinations of ctrl, shift and alt?


Thanks,


Joshua


Sorry guys, I am a novice at this. Do I put the code application.onkey
(key, procedure) into the respective subroutine that I am assigning it
to, or can I put all my onkey code together (i.e. not as a line of a
subroutine)

Joshua
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default shortcut keys

On Dec 10, 1:03*pm, Gord Dibben <gorddibbATshawDOTca wrote:
Type onkey into the help diaolog when in the VBE

All combos are listed with usage instructions and examples

Gord Dibben *MS Excel MVP

On Wed, 10 Dec 2008 07:50:57 -0800 (PST), cass calculator

wrote:
Could you please show me a simple example for how to use the OnKey
method for combinations of ctrl, shift and alt?


Thanks,


Joshua


As an example, I have the following code that highlights all the
precedents of a selection, and I'd like to assign it to the shortcut
Ctrl + Shift + J

Sub HighlightPrecedents()
Dim rngCell As Range
For Each rngCell In Selection
rngCell.ShowPrecedents
Next rngCell
End Sub

Where do I put the following code?

Application.OnKey "^+{J}, "HighlightPrecedents"
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default shortcut keys

On Dec 15, 10:47*am, cass calculator wrote:
On Dec 10, 1:03*pm, Gord Dibben <gorddibbATshawDOTca wrote:

Type onkey into the help diaolog when in the VBE


All combos are listed with usage instructions and examples


Gord Dibben *MS Excel MVP


On Wed, 10 Dec 2008 07:50:57 -0800 (PST), cass calculator


wrote:
Could you please show me a simple example for how to use the OnKey
method for combinations of ctrl, shift and alt?


Thanks,


Joshua


As an example, I have the following code that highlights all the
precedents of a selection, and I'd like to assign it to the shortcut
Ctrl + Shift + J

Sub HighlightPrecedents()
* *Dim rngCell As Range
* *For Each rngCell In Selection
* * * *rngCell.ShowPrecedents
* *Next rngCell
End Sub

Where do I put the following code?

Application.OnKey "^+{J}, "HighlightPrecedents"


I tried it inside the procedure and got the following error - the
macro 'highlightprecedents()' cannot be found. Can someone help!
thanks.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut Keys Shivali Sadavarte Excel Programming 2 February 22nd 08 02:20 PM
Macro Shortcut Key Conflicts with Application Shortcut Keys Jordan Hotzel Excel Programming 0 October 13th 06 06:39 AM
Macro Shortcut Key Conflicts with Application Shortcut Keys Jordan Hotzel Excel Programming 0 October 13th 06 06:39 AM
Shortcut Keys John Whelan Excel Programming 4 April 10th 04 03:54 PM
Shortcut Keys Jase Excel Programming 0 September 11th 03 06:04 AM


All times are GMT +1. The time now is 09:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"