ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.OnKey problem (https://www.excelbanter.com/excel-programming/288927-application-onkey-problem.html)

Phillip Reeves[_2_]

Application.OnKey problem
 
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

Phillip Reeves[_2_]

Application.OnKey problem
 
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.


All times are GMT +1. The time now is 08:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com