Application.OnKey problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I'm trying to disable number entry in an Excel workbook. I use:

Application.OnKey "1", vbNullString
Application.OnKey "2", vbNullString
etc.

My problem is that this doesn't disable the entry of "1", "2", etc. on the numeric keypad (with NumLock on), just those above the letter keys.

Any ideas?

Thanks, Phillip
 
OK, I've solved my own problem! For anyone interested, it's via using:

Application.OnKey "{96}" to "{105}" for the numberpad numeric keys, with "{106}" - "{111}" for the other numberpad keys [/*-+.].

Should've googled the newsgroups first, sorry. Discovered all the codes by looking at the KeyCode value from the KeyDown event on a MSForms TextBox.
 

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

Back
Top