Closed Thread
Results 1 to 7 of 7

how do I get past a "delete, cancel" button during a macro loop?

  1. #1
    Registered User
    Join Date
    08-11-2009
    Location
    Gilbert, Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    82

    how do I get past a "delete, cancel" button during a macro loop?

    I would choose to select the delete button. I've created a new worksheet within a workbook, insert text and formatting, and copied to a specific place in the active worksheet. Everything works well except 1. there is a LOT of coding because I recorded the macro and 2. the delete message pops up for every files the macro manipulates. I have to click "delete" about 60 times throughout this macro and would love to be able to let it click its own delete button!

    I'll attach an example.

    Thanks.
    Attached Files Attached Files
    Last edited by curbster; 08-12-2009 at 06:40 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: how do I get past a "delete, cancel" button during a macro loop?

    Hello Curbster,

    The statement Application.DisplayAlerts will select the default button automatically for a dialog when set to false. This prevents you from ever seeing the dialog. When deleting a worksheet, the default button is Delete. Here is the worksheet deletion routine with the added code...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-11-2009
    Location
    Gilbert, Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    82

    Re: how do I get past a "delete, cancel" button during a macro loop?

    Worked like a charm! thank you!

    I don't get prompted anymore and it glides on through.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how do I get past a "delete, cancel" button during a macro loop?

    Curbster, take a gander through this slimmed down version of your code. It appears you recorded yourself doing thing multiple times, which lengthened the code a bit. Also, the recorder records everything you do including selecting cells, something a macro doesn't usually need to do.

    Compare this to your original code and you'll see how you can edit out a lot of unnecessary code that also gets recorded along the way.

    FYI.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-12-2009 at 09:44 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how do I get past a "delete, cancel" button during a macro loop?

    Deleted, see below.
    Last edited by JBeaucaire; 08-12-2009 at 09:43 PM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how do I get past a "delete, cancel" button during a macro loop?

    Actually, it gets even shorter, this is about half the size of the original macro:
    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-12-2009 at 09:44 PM.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: how do I get past a "delete, cancel" button during a macro loop?

    Hello JB,

    Your input is appreciated. Please follow the forum rules and don't post when the OP has marked the thread solved.

Closed 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