+ Reply to Thread
Results 1 to 10 of 10

HOW TO: Pause loop, fix error on a popup UserForm, continue loop

  1. #1
    Registered User
    Join Date
    02-07-2014
    Location
    Miami
    MS-Off Ver
    Excel 2003
    Posts
    18

    HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    Hello experts,
    I have a "for each... next (cell)" loop that runs through column B and validate some customers data.
    I want to do the following trick

    If one error is found in a customer's information then
    pause the loop, open a popup UserForm with the customer information, fix it and then click "Save & Continue" close the userform, and continue the loop...
    again and again every time an error is found.

    thanks,
    AndyMachin

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    What do you have so far? Putting this logic in the middle of a For loop is not difficult, but have you built the UserForm and the logic needed to use it to edit a record?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    02-07-2014
    Location
    Miami
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    Quote Originally Posted by 6StringJazzer View Post
    What do you have so far? Putting this logic in the middle of a For loop is not difficult, but have you built the UserForm and the logic needed to use it to edit a record?
    Hello,
    I have not create the form yet, non the code. That part is gonna be easy.
    basically what I have is something like this:

    colA ColB ColC ColD etc etc
    data data data data
    data data data data

    so maybe I am gonna do somethin like:

    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    Please Login or Register  to view this content.
    so, thats it
    Last edited by 6StringJazzer; 06-19-2014 at 01:09 PM.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    Quote Originally Posted by AndyMachin View Post
    I have not create the form yet, non the code. That part is gonna be easy.
    I'm glad you think that part's easy, because this part is even easier The form does all the work once the call to Show opens it. When the form closes, execution resumes after the call to Show below.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-07-2014
    Location
    Miami
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    Thank you, I am sorry for the tags...
    So, can I call a form in the middle of the execution without anything special like vbmodeless or something like that? When I close the form the loop will continue itself without any code to indicate it to continue?

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    That is correct. The only time you need to worry about modeless is if you need to have multiple forms active for user input at the same time. Your form will have some kind of OK button that the user will press when he's done making changes. Your form code will look something like this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-07-2014
    Location
    Miami
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    Thank you, I understand but there is another question...
    When the user fix the error found, how do I refer the fix to the correct rCell or rCell offset, is this a kind of ActiveCell??
    I ask because I assume that the form (the OK button) have an independent code from the variables rCell and rRng

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,720

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    One way to do this is to pass rCell as an argument to a Sub in the form. Here's how I would do it, but this is not the only way. Updates to the version above are shown in red. I have not tested this specific code but would be happy to do if you attach your file.

    Please Login or Register  to view this content.
    Code in the form module:
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-07-2014
    Location
    Miami
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    thank you!!, I will prepare and try everything now and I'll let you know if works ASAP :D :D

  10. #10
    Registered User
    Join Date
    02-07-2014
    Location
    Miami
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: HOW TO: Pause loop, fix error on a popup UserForm, continue loop

    hello!
    many thanks for your help, I was trying and I found a simple way to do it, just need one little part of your code which I really really really appreciate...
    well here we go for someone who find this interesting
    my changes in bold blue

    Please Login or Register  to view this content.
    and the code in the form module
    Please Login or Register  to view this content.
    SOLVED!! :D

+ 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. Continue next iteration of For loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-22-2013, 02:09 AM
  2. Need loop to continue instead of end
    By lordterrin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-26-2013, 07:01 PM
  3. Macro Loop Broken. Detects Max but doesn't continue loop
    By herchenbach in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2011, 12:17 PM
  4. Pause Loop
    By toocold in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2008, 12:42 PM
  5. wait/pause during loop
    By _Terry_ in forum Excel General
    Replies: 4
    Last Post: 07-04-2008, 03:22 PM

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