+ Reply to Thread
Results 1 to 6 of 6

Adding a special delete confirmation box

  1. #1
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Adding a special delete confirmation box

    Hi guys, Charles on this forum helped me by creating the code on the following example sheet that would delete all records of a specified number on 2 other worksheets within the book. His work is here:

    Example-3.xlsm


    It works perfectly. What I've decided however, is that there may be too much information at stake to be deleted with a simple button click and confirmation box. So what I would like to see is a special confirmation box prior to the existing one that would weed out all accidents. I am visualizing this "confirmation box" as being, in fact, a userform that is triggered instead of the confirmation box. This userform will have one field and 2 buttons. The user would have to type the word "delete" into the field then hit the "proceed" button that would then bring him/her to the existing confirmation box. The other button being "cancel" of course. I would like it so that when anything other than "delete" is submitted the sheet simply closes the userform and pops up a msg box saying "Invalid command. No action taken."

    This would prevent someone from accidentally hitting the delete button and just powering through the prompt without really reading it, causing unwanted data loss.
    Last edited by nohero; 06-21-2011 at 01:30 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Adding a special delete confirmation box

    nohero,

    Attached is a modified version of your sample workbook. Let me know if that works for you.

    ~tigeravatar
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Adding a special delete confirmation box

    This appears to be perfect! At first I was a little concerned that the focus shifts over to the Orders worksheet when the confirmation box pops up but then I tried it with the Orders ws hidden and it works exactly how I wanted.

    Thanks a lot!

  4. #4
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Adding a special delete confirmation box

    Hey, hope it's not bad manners to re-open my thread previously marked as "solved" but I ran into a couple of snags.

    1- The 'if' statement used in the code to identify which worksheets will be filtered is set to only make my "Main" sheet exempt:

    Please Login or Register  to view this content.

    I've now decided to add 2 new sheets to my workbook and want them to be exempt for the coding in these sections as well. How do I modify the above code to list 3 sheets to either include sheets not named "Main", "FullList" and "Inventory" or to only include "ProductData" and "Orders" sheets?


    2- I originally said I didn't mind that when the "delete" confirmation box popped up my wb was focusing on a different ws other than "Main". Well, I'm starting to think it would be best that my "Main" ws stayed in focus when that box popped up. How do I modify the code to make this happen?

    If you need an example of the workbook, please use the one a couple of posts up from tigeravatar.

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Adding a special delete confirmation box

    nohero,

    Quote Originally Posted by nohero View Post
    I've now decided to add 2 new sheets to my workbook and want them to be exempt for the coding in these sections as well. How do I modify the above code to list 3 sheets to either include sheets not named "Main", "FullList" and "Inventory" or to only include "ProductData" and "Orders" sheets?
    Updated the If line to the following:
    Please Login or Register  to view this content.
    Quote Originally Posted by nohero View Post
    I'm starting to think it would be best that my "Main" ws stayed in focus when that box popped up. How do I modify the code to make this happen?
    In the Userform_Initialize event, added the following to keep the Main ws visible
    Please Login or Register  to view this content.


    Attached is the updated version of the workbook.

    Hope that helps,
    ~tigeravatar
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Adding a special delete confirmation box

    Ok, this time I think it's perfect for real lol.

    I think I'm getting close to getting the hang of this VB stuff, your solution to my first point was almost exactly what I tried, I missed the _ at the end of the lines. Your solution to my second problem I had tried in the wrong spot.

    Thanks again, you've been a HUGE help.

+ 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