ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Prompt Before Cell Deletion (https://www.excelbanter.com/new-users-excel/50439-prompt-before-cell-deletion.html)

Kryptonix

Prompt Before Cell Deletion
 

Hiya,

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

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


Thanks

Kevin


--
Kryptonix
------------------------------------------------------------------------
Kryptonix's Profile: http://www.excelforum.com/member.php...o&userid=28108
View this thread: http://www.excelforum.com/showthread...hreadid=476187


swatsp0p


I'm sure what you ask is possible via VBA code. However, I would
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 to
do is erase the cell contents in the formula bar via backspace, simply
press the space bar then enter or just enter another value in the cell
to bypass the pop-up. Finally, there is the question of would you
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.


--
swatsp0p


------------------------------------------------------------------------
swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101
View this thread: http://www.excelforum.com/showthread...hreadid=476187


Kryptonix

Prompt Before Cell Deletion
 

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


--
Kryptonix
------------------------------------------------------------------------
Kryptonix's Profile: http://www.excelforum.com/member.php...o&userid=28108
View this thread: http://www.excelforum.com/showthread...hreadid=476187


Kryptonix

Prompt Before Cell Deletion
 

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


--
Kryptonix
------------------------------------------------------------------------
Kryptonix's Profile: http://www.excelforum.com/member.php...o&userid=28108
View this thread: http://www.excelforum.com/showthread...hreadid=476187



All times are GMT +1. The time now is 08:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com