Disable Backspace and Delete key on specific Sheets

hajiali

Well-known Member
Joined
Sep 8, 2018
Messages
626
Office Version
  1. 2016
Platform
  1. Windows
I thought this was going to be easy as

Code:
[COLOR=#3366CC]Private Sub Workbook_Activate()[/COLOR]    Application.OnKey "{BACKSPACE}"
    Application.OnKey "{DELETE}"

End Sub

Private Sub Workbook_Deactivate()
    Application.OnKey "{BACKSPACE}"
    Application.OnKey "{DELETE}"[COLOR=#3366CC]End Sub[/COLOR]

Apparently its not working when adding this code its disables on all sheets in the workbook. I would like to be able to just disable Backspace and delete on specific sheet and not all sheets.
 
I suggest putting my code in a empty workbook with no other code and see if it works.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
The problem with this type code is you want:
When certain sheets are activated you want the keys to do one thing
When you deactivate certain sheets you want that to no longer work


I'm not real familiar with activating and then deactivating sheets.

So maybe someone else here will be able to help you.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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