+ Reply to Thread
Results 1 to 5 of 5

Break out of loop

  1. #1
    mpeplow
    Guest

    Break out of loop

    right now I am using the DoEvents statment withing my loop to allow the user to click on buttons while the loop is running, a cancel button to be specific, the command that I am using when that button is press is END, this works great for the most part however that command completly stops the macro and exits everything, If I put any code after that statement, it does nothing, I was wondering what I would need to do to keep the form from closing?

  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,258
    Hello Mpeplow,

    To exit a FOR loop use Exit For
    To exit a DO loop use Exit Do

    To exit a SUB use Exit Sub
    to exit a FUNCTION use Exit Function

    Sincerely,
    Leith Ross

  3. #3
    mpeplow
    Guest
    This command does not work outside of the loop. I don't understand how I would use this a condition if a button on a form is pressed.
    Last edited by mpeplow; 04-18-2007 at 10:01 AM.

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

    To solve your problem, I would need to see your code. Since this involves a UserForm, it would be best if you post the entire workbook as an attachment.

    Thanks,
    Leith Ross

  5. #5
    mpeplow
    Guest
    I would love to so you could help me, however, unfortunatly, I cannot post the entire workbook. I'm working with propriatary information, I would probally get in alot of trouble for posting it. I have been looking over my code and think that I can use the information that you gave me to force it to work how I want it to.

    Thanks!

+ 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