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

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
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..
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,582
Members
449,039
Latest member
Arbind kumar

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