+ Reply to Thread
Results 1 to 4 of 4

Prompt Before Cell Deletion

  1. #1
    Registered User
    Join Date
    10-14-2005
    Posts
    8

    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

  2. #2
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    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.
    Bruce
    The older I get, the better I used to be.
    USA

  3. #3
    Registered User
    Join Date
    10-14-2005
    Posts
    8
    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
    Last edited by Kryptonix; 10-17-2005 at 05:20 AM.

  4. #4
    Registered User
    Join Date
    10-14-2005
    Posts
    8
    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1