+ Reply to Thread
Results 1 to 13 of 13

How to capture deletions of row(s) "event"

  1. #1
    Forum Contributor michellepace's Avatar
    Join Date
    10-28-2015
    Location
    South Africa
    MS-Off Ver
    2013
    Posts
    132

    Question How to capture deletions of row(s) "event"

    Hello there,

    Requirement: I would like to capture the "event" of rows being deleted in a sheet, in particular I need to capture the first and last row being deleted.

    I'm really struggling with this as I have been at it for the last two days. I have tried to do this with the below code but it does not work consistently - sometimes the (2) code is reached and sometimes not. I'm sure there must be a better way to satisfy my requirement. Could anyone please provide a suggestion?

    Please Login or Register  to view this content.
    Thanks in advance,
    Michelle

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to capture deletions of row(s) "event"

    Hi,

    Try

    Please Login or Register  to view this content.
    The penultimate two lines seem to be necessary to get rid of a thick black border that gets left otherwise.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: How to capture deletions of row(s) "event"

    Hi Richard

    might be missing something but I encountered a couple of problems.

    The first is that, if I select whole rows and press the Delete key, it errors out with Run Time error 1004. If I use the Delete icon on the Home ribbon, it's OK.

    This can be overcome by:

    Please Login or Register  to view this content.
    But, bigger problem, I can't actually type anything into the spreadsheet. It just tells me the row and undoes the typing

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: How to capture deletions of row(s) "event"

    This might work for you. It depends on column A being fully populated, that is, a key field that will have data in every row.

    Please Login or Register  to view this content.
    Note that it is possible to Undo any changes as event handlers are storing or reporting but not changing anything.


    Regards, TMS

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to capture deletions of row(s) "event"

    Morning Trevor,

    That's strange since it's still working for me here. See attached video.

    Oh, even a short 7 second video @ 300Kb is seemingly too big for the forum

    Here's what I did.

    Select a few rows by clicking in the row numbers area, move to the ribbon Cells area and hit delete, or indeed hit the delete key.


  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: How to capture deletions of row(s) "event"

    That's why I said I might be missing something . As your code stands, if I use the Delete key, I get an error 1004 on the Undo. If I use the Delete icon, I'm okay. But that's fixable. However, if I just type anything the Undo undoes the typing but then deletes the row

    So, if I switch off the event handler for a moment and populate column A with some data, then switch on the event handler, if I type anywhere, the whole row will be deleted. That's because, regardless of what the change is, you have:
    Please Login or Register  to view this content.
    I'm thinking that can't be right

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to capture deletions of row(s) "event"

    ...sorry for the confusion

    I meant the code to be the mechanism for deleting the selected rows. I hadn't considered other changes like adding values to the sheet. But this could be overcome by wrapping the code in an
    Please Login or Register  to view this content.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: How to capture deletions of row(s) "event"

    OK, on same page

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to capture deletions of row(s) "event"

    Excellent!

    FYI I'm now 7 months and counting on that other little local difficulty at LJLA with VCS. Everything is quite on the western front since my first (and hopefully last) communication with their DR Co.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: How to capture deletions of row(s) "event"

    Ah, I never got as far as being handed off to DR. Did you know VCS actually pay LJLA as opposed to what you might have expected?

  11. #11
    Forum Contributor michellepace's Avatar
    Join Date
    10-28-2015
    Location
    South Africa
    MS-Off Ver
    2013
    Posts
    132

    Re: How to capture deletions of row(s) "event"

    Hi TMS and Richard,

    Thank-you both for your replies, incredibly useful! It took me a while to work through it line by line and finally I understand the solution.

    Thank-you both for taking the time to answer my question.

    Michelle

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: How to capture deletions of row(s) "event"

    You're welcome. Thanks for the rep.

  13. #13
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to capture deletions of row(s) "event"

    My pleasure and thanks for the rep.

+ 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. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  2. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  3. Capture user click event problem, "the expression you entered requires the control to
    By shinichi_nguyen in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2012, 04:38 PM
  4. ""All Day Event"" Check Box Issues
    By champs in forum Outlook Formatting & Functions
    Replies: 1
    Last Post: 04-03-2009, 07:10 AM
  5. Code to capture recalculated cells - "Date last modified" utility
    By Tristan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2008, 11:58 AM
  6. [SOLVED] How to "Capture" Records Found Number During AutoFilter
    By Paputxi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2006, 10:45 PM
  7. [SOLVED] Capture "after delete" Worksheet
    By Rony Boter in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-30-2005, 11:05 PM
  8. Capture "Cancel" from login request.
    By Claus Mygind in forum Excel General
    Replies: 0
    Last Post: 06-20-2005, 09:05 AM

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