+ Reply to Thread
Results 1 to 16 of 16

Do Until Loop error "Loop without Do"

  1. #1
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Do Until Loop error "Loop without Do"

    Hi
    Just so you know, I'm eons away from being proficient in VBA. This is the first time that I've used the Do Until Loop. MY macro works perfectly (without the loop statements). When I place them in, I get this error (Loop without do). I need the loop to allow entry issues to be able to re-try. I mimicked the examples that I found online, but it doesn't seem to work for my application (can't figure out why). I don't think it needs too much tweaking as it does work well Any help will be greatly appreciated Jim
    Here is the code that I want to use:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Do Until Loop error "Loop without Do"

    Hi Effexus3:

    Try this:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    Thanks Robert...It's almost great. The loop works fine but there are some problems
    If I hit Cancel, Ok, (without entering any data) in the 1st password box... or X the program opens full out
    If I hit the X in the limited access MsgBox it gives me full access
    Maybe needs a few tweaks yet
    This may have been happening before but I'm not sure
    Jimmy
    SomePlansFailOnExecution

    AllPlansFailWithout

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Do Until Loop error "Loop without Do"

    Hi Jimmy,

    Not too sure what you mean. I programmed the code that if the user clicks Cancel, X on the Inputbox dialog or doesn't enter any data and then clicks OK the script just stops (this is what Exit Sub does).

    Robert
    Last edited by Trebor76; 11-05-2019 at 01:30 AM.

  5. #5
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    Hi Robert. it looks like the lines: ( If Len(A1) = 0 Then 'User clicked Cancel Exit Sub) & ( If Len(A2) = 0 Then 'User clicked Cancel Exit Sub)... kicks them out of the ballpark if there is no entry. Maybe you can suggest what I can replace these with?
    Thanks Jim

  6. #6
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    Well it opens it up totally accessible. Sorry I didn't see your reply while i was typing

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Do Until Loop error "Loop without Do"

    kicks them out of the ballpark if there is no entry.
    Correct - what do you want the code to do when this happens?

  8. #8
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    I need the workbook to remain protected, until the procedure is followed through. The MsgBox's & Input boxes drive the protection...as soon as we disable this, by exiting, it leaves the procedure wide open. Obviously if a person doesn't follow the exact method, and it leaves the program unprotected, that seems to defeat the whole password process. Not trying to be unreasonable
    Thanks Jim

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Do Until Loop error "Loop without Do"

    No where in your original code does protection come in to it The workbook will be in the same state as before the code was run.

    I can't offer any other advice I'm afraid.

    All the best with it.

    Regards,

    Robert
    Last edited by Trebor76; 11-05-2019 at 02:29 AM.

  10. #10
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    Hi Robert
    If the user enters nothing and/or hits X or Ok without data I need it to progress to the box advising that it is not the proper password and to try again or go to guest. At least that would protect for the password box.
    In the Guest box area. It should go to msgbox that advises limited access which will in turn call Delete Sheets.
    If you can help me with this, I'd really appreciate it. You've been a great help
    Thanks Jim
    Hitting the sack. will check back tomorrow afternoon
    Thanks again for your patience

  11. #11
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    Again i missed your last post..Thanks for your help..I'll figure this out..you got me past the Do/Loop and I appreciate that
    Jim

  12. #12
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Do Until Loop error "Loop without Do"

    If you can help me with this
    I can't I'm afraid Someone here will be able to I'm fairly sure

  13. #13
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    Thanks for your assistance. It was very helpful
    Jim

  14. #14
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Do Until Loop error "Loop without Do"

    Have a look at this potential alternative that I answered yesterday.

  15. #15
    Registered User
    Join Date
    10-13-2019
    Location
    Windsor, Canada
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: Do Until Loop error "Loop without Do"

    Problem Solved

  16. #16
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Do Until Loop error "Loop without Do"

    Great!! If you could mark the thread as solved (refer the link in my signature) it would be appreciated.

+ 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. Problem at saving sencond file in a loop "Run time error '9'"
    By tuxo99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2016, 05:40 AM
  2. [SOLVED] Loop Creates "item not found error" on second pass
    By phbryan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-16-2014, 02:24 PM
  3. Error handling--resume next loop, but for a "DO WHILE" loop
    By submariner18 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-18-2012, 05:35 PM
  4. "Object required" error with VBA loop rows deleting
    By JKWIN in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-22-2012, 09:31 AM
  5. Array loop producing error "Run time error '1004'"
    By jeskit in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-06-2011, 08:56 AM
  6. For each loop, 1004 error, if ... then "activecell.offset" attempt
    By AdamParker in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-22-2010, 03:30 PM
  7. Replies: 5
    Last Post: 09-12-2005, 04:05 AM

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