Application.OnKeys not working

mcomp72

Active Member
Joined
Aug 14, 2016
Messages
305
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
In my Excel workbook, I am trying to create a keyboard shortcut. I have chosen to use Ctrl-Alt-G, because it appears Excel is not already using it.

In the Workbook_Activate sub, I am calling a sub called AssignShortcuts. Here it is.

VBA Code:
Sub AssignShortcuts()

'This is supposed to set Ctrl-Alt-G to open a UserForm.
Application.OnKey "^%G", "LoadGroupsUF"

MsgBox "AssignShortcuts has run!"

End Sub

This sub is in a standard module, and LoadGroupsUF is in a standard module.

I put in the MsgBox line to confirm the code is running when the workbook is opened. It is.

I put a breakpoint on the first line of LoadGroupsUF. That way, if it is every called, the code should stop. I then tried pressing Ctrl-Alt-G. Nothing. I tried multiple times. Nada. I saved & closed the file, reopened it, and tried again. Still nothing. Obviously I'm doing something wrong, but I'm not sure what.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,222,905
Messages
6,168,950
Members
452,228
Latest member
just4jeffrey

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