OnKey question

Eli Panic

New Member
Joined
Apr 18, 2018
Messages
4
I have a control page with a single cell named range 'LETTER' to determine my index letter for filtered lists on another sheet. I want a shortcut to be able to change the index letter without having to leave my list sheet. To do this I have set up the following:

Code:
Sub HotKeys()
Application.OnKey "^%+A", "'ChangeLetter ""A""'"
Application.OnKey "^%+B", "'ChangeLetter ""B""'"
Application.OnKey "^%+C", "'ChangeLetter ""C""'"
Application.OnKey "^%+D", "'ChangeLetter ""D""'"
...
Application.OnKey "^%+Z", "'ChangeLetter ""Z""'"
End Sub

Code:
Sub ChangeLetter(Arg As String)
Worksheets("Control").Range("LETTER") = Arg
End Sub

The code is activated and deactivated with the appropriate Worksheet_Activate and Worksheet_Deactivate events.

This all works pretty well, but my problem is that some of the key combinations ([Ctrl][Alt][Shift][Letter]) are already mapped to other functions from outside of Excel, and these take precedence over my attempted shortcuts.

Does anyone know of a more elegant or an alternative method of achieving my aims?

Thanks
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
How about using a dropdown in a cell (say A1)
- select from A-Z
- change in value in A1 triggers Worksheet_Change
- Worksheet_Change amends value of Range("LETTER")

Place in sheet module
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address(0,0) = "[COLOR=#ff0000]A1"[/COLOR] Then Worksheets("Control").Range("LETTER") = Target.Value
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,274
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top