Prompt Before Cell Deletion

  • Thread starter Thread starter Kryptonix
  • Start date Start date
K

Kryptonix

Hiya,

I have an excel spreadsheet that I would like to change so that when\i
someone hits the delete key whilst in a cell a prompt appears askin
them to confirm that they wish to delete the contents of a cell. I
this possible?

Apologies if I have posted this in the wrong forum, I am a newish use
and new to the site so was unsure whether to post here or th
Programming forum.


Thanks

Kevi
 
I'm sure what you ask is possible via VBA code. However, I woul
question the logic behind such a move. First, that type of 'pop-up
box is extremely annoying (ranks up there with flashing cells).
Second, it would not take long to figure out that all I would need t
do is erase the cell contents in the formula bar via backspace, simpl
press the space bar then enter or just enter another value in the cel
to bypass the pop-up. Finally, there is the question of would yo
apply this pop-up to a single cell only or to any selected range
regardless of size?

Are you sure this is the route you want to go?

p.s. This forum is fine for this posting
 
Hi Bruce,

Thanks for the reply,

Yes, the guy whose spreadsheet it is has asked me to try and do this
for him so that he doesn't accidently delete anything, not
realise..then save over it. He does need to delete parts of the
spreadsheet now and then.

The pop up would need to apply on the whole spreadsheet so that if the
delete key was pressed anywhere on it the pop-up would appear.

If you could point me in the right direction on the VBA code that would
be great as I would like to give it a trial and see if he's happy with
it.

Thanks

Kevin
 
Hiya,

Just an update, I have done some investigation and have come up with
the following code which seems to do what I want.

Sub proDangerousProcedure()

YesNo = MsgBox("Are you sure you wish to delete this data?", vbYesNo +
vbCritical, "Warning!!!!")
Select Case YesNo
Case vbYes
Macro1
Case vbNo
Exit Sub
End Select

End Sub


When I run a Macro I created the message pops up and if I say yes it
delete's the data and if it doesn't it leaves it.

This is great, my only problem now is how to get the macro to run when
I press the delete key on the keyboard? is this possible? At the
moment it works if I press a button I created on the toolbar but would
like it to activate it by pressing the delete key also.

Any elp would be gratefully appreciated :)

Thanks

Kevin
 
Back
Top