Stop user from pressing the "Delete" key in speci

MattOCUSA

Board Regular
Joined
Jan 12, 2007
Messages
231
I have 3 cells on 1 worksheet which I cant have the user delete by pressing the "Delete" key on the keyboard.

I need to allow the user to select the 3 cells for other reasons, so protecting the cells wont work in this case. I'm wondering how to do it via worksheet event code? I'd need something that would replace the value in the cell if they deleted the contents of the cell by pressing the delete key in those cells?

Thank You!
Matt
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
If the values in these particular cells are always going to be the same, then you could use something like this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" And Target.Value <> 2 Then Target.Value = 2
End Sub

Repeat the “If” line for each cell address as required.

This particular example will return cell A1 to the value “2” if it is changed/deleted.
 
Upvote 0
Hi thanks. The user enters a value into these cells via an Input Box. The values change though or else that would work.
 
Upvote 0
The only other way I can think of doing this then, is to use the input box to enter the value into both the cell that it currently is doing and also another (possibly hidden) cell on the worksheet. Then refer to the hidden cell in the code rather than the constant value “2”.

Incidentally, what other reasons do you need the users to select the cells for? Is it not something you can customise in the protect worksheet dialog box? (assuming you are using later than xl2000 version).
 
Upvote 0
Hi, thanks for the ideas. I ended up solving it.

THANK YOU for taking time to help out.

Matt
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,787
Members
449,049
Latest member
greyangel23

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