+ Reply to Thread
Results 1 to 4 of 4

Using 'Delete' key without deleting

  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2016
    Posts
    140

    Using 'Delete' key without deleting

    Hello all,

    What I am trying to do is:
    • User is on A1
    • Presses 'Delete' / 'DEL'
    • Contents of A1 remains but a window appears asking if they would like to delete entire row
    • If user chooses 'Yes', it doesn't delete but strikes through the row


    I have got it all except for code to stop the cell being delete when the key is pressed, is there such a code.?



    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using 'Delete' key without deleting

    If you have "... got it all except ..." it might have been useful to see what you do have - that helps so an answer can be provided in the context of the existing code.

    Regardless, in the sheet Class module this is to apply to:
    Please Login or Register  to view this content.
    And in a standard Code module:
    Please Login or Register  to view this content.
    Note: This does not trap rows being deleted, just a press of the DEL button.
    Last edited by cytop; 11-13-2013 at 05:53 AM.

  3. #3
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 2016
    Posts
    140

    Re: Using 'Delete' key without deleting

    Thanks cytop....

    User presses <Delete> key on cell A1, code checks to see if cell A1 has changed and if it is blank. If it is blank it calls up 'Row.Clear';
    Please Login or Register  to view this content.
    'Row.Clear' calls up a window and the user has two buttons, <yes> and <no>. If <yes> is chosen, the following code is used;
    Please Login or Register  to view this content.

    As it is at the moment, when <delete> is pressed, the contents of the cell is deleted before the script is run - I don't want that to happen.
    Is it the same code as above and how do I merge that code into the above.?


    Thank you again.

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Using 'Delete' key without deleting

    There's a difference in the approach. Yours' is reactive - you allow the change and then manipulate the cells. A simple
    Please Login or Register  to view this content.
    in the right place (I didn't look to see where that is...) should do it.

    If you want a different approach, the code I posted is proactive - it stops the Delete key from actually deleting the data in the first place...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] I can't delete a cell without deleting a row
    By Tenny in forum Excel General
    Replies: 4
    Last Post: 10-15-2019, 06:14 AM
  2. [SOLVED] Entirerow.Delete - Not deleting all rows.
    By Knocknaboula in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2013, 02:15 PM
  3. Macro to delete contents of 2 directories not deleting the second
    By RebeccaEllis in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-09-2012, 04:57 PM
  4. Can't delete a table without deleting the data?
    By JapanDave in forum Excel General
    Replies: 3
    Last Post: 07-08-2009, 03:46 AM
  5. [SOLVED] how do I delete numbers without deleting formulas
    By Emmaus junkie in forum Excel General
    Replies: 1
    Last Post: 10-08-2005, 05:05 PM

Tags for this Thread

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