Consulting

Results 1 to 5 of 5

Thread: Solved: Bottom controlled Do While loop

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Solved: Bottom controlled Do While loop

    Struggling with the concept. Can anyone provide an example? Example. Start the loop and then have an input box asking if you want to continue the loop?
    Peace of mind is found in some of the strangest places.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Doesn't sound complicated but I think we need a simple example.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    [VBA]Do
    Rem some stuff
    Loop Until MsgBox("Another Loop?", vbYesNo) = vbNo[/VBA]

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi all,

    I would imagine you meant a msgbox, but here's a simple example of either way.

    Sub LoopCrazy()
    Dim i As Long, bolOkayIveHadEnough As Boolean
        
        Do
            i = i + 1
            
            If Not MsgBox("We're in Loop #" & i & vbCrLf & _
                          "Do you want to continue?", vbYesNo, vbNullString) = vbYes Then
                           
                bolOkayIveHadEnough = True
            
            End If
        Loop While Not bolOkayIveHadEnough
        
    End Sub
        
    Sub LoopyToo()
    Dim i As Long
        
        Do
            i = i + 1
        Loop While InputBox("""Yes"" to continue" & vbCrLf & "Loop #" & i, "") = "Yes"
        
    End Sub
    Mark

  5. #5
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Thanks guys I got it.
    Peace of mind is found in some of the strangest places.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •