Consulting

Results 1 to 1 of 1

Thread: Do While Loop will not execute

  1. #1
    VBAX Newbie
    Joined
    Feb 2014
    Posts
    1
    Location

    Do While Loop will not execute

    Disregard! I figured it out! Thanks!

    I'm unsure as to why the loop won't execute. It goes to the first line of the Do While loop, then instantly goes to End Sub. Any thoughts?


    Sub test()Dim i, c, d As Integer
    Dim PN, Index As String
    
    
        i = 1
        c = 2
        d = 2
        PN = Cells(c, 6)
        Index = Cells(d, 16)
        
        Do While Cells(c, 6) <> ("") And Cells(d, 16) = ("")
            Sheets(CPB).Select
            
            If Cells(c, 6) <> ("") And Cells(d, 16) = ("") Then
                Range("A" & c & "P" & d).Select
                Selection.Copy
                Sheets(PB).Select
                ActiveSheet.Paste
                i = i + 1
                c = c + 1
                d = d + 1
                
            ElseIf Cells(c, 6) <> ("") And Cells(d, 16) <> ("") Then
                i = i + 1
                c = c + 1
                d = d + 1
                    
            Else
                Exit Do
            End If
        Loop
        
    End Sub
    Last edited by mars1886; 02-11-2014 at 07:54 AM. Reason: Solved

Tags for this Thread

Posting Permissions

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