+ Reply to Thread
Results 1 to 5 of 5

EXCEL: Protect Rows Being Deleted.

  1. #1
    Forum Contributor
    Join Date
    12-28-2012
    Location
    Mumbai - India
    MS-Off Ver
    Excel
    Posts
    145

    EXCEL: Protect Rows Being Deleted.

    Dear All

    I' am looking for a code which will popup a message when user try to delete entire rows

    msg = "Are you sure about deleting selected rows?"

    if user select Yes - rows should deleted
    if user select No - rows should not deleted [undo]

    thanks
    MG

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: EXCEL: Protect Rows Being Deleted.

    Hi, MG,

    AFAIK there´s no event that will be triggered when a row or several rows/columns are deleted. What you may monitor is if a user selects an entire row (or several rows) via the SelectionChange-Event and compare the number of cells in the first row of the selection to the number of columns. A static code may look like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    12-28-2012
    Location
    Mumbai - India
    MS-Off Ver
    Excel
    Posts
    145

    Re: EXCEL: Protect Rows Being Deleted.

    Thanks Holger for your reply

    Still if we use the code mentioned by you, I' am not able to get the deleted row even after selecting "No" from message.

    It should do undo.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: EXCEL: Protect Rows Being Deleted.

    Hi, gaikwad.mm,

    there´s no Delete in my piece of code if No was chosen. For me the proper way of working here would be to check first and delete after confirmation not delete first and then ask if the delete was correct.

    Command for restoring would be Applicaiton.Undo but AFAIR the Delete would have to be in the same macro to enable that command (and it may conflict with Events in the worksheet if there are any events fired from that).

    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    12-28-2012
    Location
    Mumbai - India
    MS-Off Ver
    Excel
    Posts
    145

    Re: EXCEL: Protect Rows Being Deleted.

    Thanks Holger

    I' have done it....

    and it is working as per requirement

    I' will update the code here in a while.

+ 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