Disable All Keys Except for Escape, Enter, Backspace and the Arrow keys...

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
1,887
Office Version
  1. 2019
Platform
  1. Windows
Hey Excel Gurus,

I would like to know if there is some sort of a code that could disable all keys except for Escape, Enter, Backspace and the Arrow keys? Would it be possible to run such a code on specific worksheets only?

Thank you and will appreciate..
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,175
Office Version
  1. 2019
Platform
  1. Windows
Hi,

What you want to do can be done using Application.OnKey method (see VBA helpfile). However, I would question why you would want to do this? If it is with intention of preventing users carrying out certain functions whilst using your application on their desktop, you may want to re-think it.

Just a personal view but taking away functionality would very likely annoy your users who may decide to disable your macros more so if you do anything that interferes with their personal desktop settings like keyboard shortcuts.



Dave
 

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
1,887
Office Version
  1. 2019
Platform
  1. Windows
Hi,

What you want to do can be done using Application.OnKey method (see VBA helpfile). However, I would question why you would want to do this? If it is with intention of preventing users carrying out certain functions whilst using your application on their desktop, you may want to re-think it.

Just a personal view but taking away functionality would very likely annoy your users who may decide to disable your macros more so if you do anything that interferes with their personal desktop settings like keyboard shortcuts.



Dave

I have sheets with very specific requirements. Maybe a User form will serve the purpose. I appreciate your reply on this topic. Application.OnKey is one of the methods, yes . However, I was hoping for a code that would work with an array of keys. as only few keys need enabling. But yet again, this is me being lazy, I definitely should begin with a user form.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,890
Messages
5,544,883
Members
410,643
Latest member
sng
Top