Assign Keybindings to a Userform

P

PaulW

I'm making a calculator type userform. It will be easier to use that for
someone to find a calculator, and will have additional options for inserting
values into the active sheet.

I've made the *current* buttons on the userform look exactly like the
numberpad on my keyboard, without the pgup, home, del, etc, just the numbers
and such.

What I'd like to do is let people simply use the numberpad on their keyboard
to "activate" the buttons on the userform, like 4, or +

I tried an
Application.OnKey "7","Command7_Click"
in the userform initialisation, but that didn't work, it threw up an error.
So I'm assuming that I can't link to a userform macro or something?
I also tried to use the "Accelerator" field, but that only works when Alt is
pressed down. And only works on the keyboard section, rather than the
numberpad. So I have one 7 that works when I press shift, but one that
doesn't.

Is there a quick way to assign the numberpad keys (including numlock) to
buttons on a userform? Since they're command buttons, it doesn't need to
press the button as such, just trigger the "commandbutton_click" event.
 
A

aidan.heritage

I'm making a calculator type userform. It will be easier to use that for
someone to find a calculator, and will have additional options for inserting
values into the active sheet.

I've made the *current* buttons on the userform look exactly like the
numberpad on my keyboard, without the pgup, home, del, etc, just the numbers
and such.

What I'd like to do is let people simply use the numberpad on their keyboard
to "activate" the buttons on the userform, like 4, or +
Wouldn't the keypress event of the form do it for you - can't check at
the moment as the PC is tied up with a long macro job, but I would
check that first!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top