+ Reply to Thread
Results 1 to 2 of 2

Compile error: Loop WIthout Do

  1. #1
    darin kelberlau
    Guest

    Compile error: Loop WIthout Do

    I get a compile error: loop without do.

    My code follows. What is wrong!? I see 2 Do's and 2 Loop's.




    Cells(1, 1).Select
    Selection.UnMerge
    Row = 2
    Do Until Row > 250
    If Cells(Row, 1) = " " Then
    If Cells(Row + 2, 1) = "" Then
    Cells(Row + 3, 1).Select
    Selection.UnMerge
    End If
    End If
    Row = Row + 1
    Loop

    'unmerge topic and obj'
    Row = 3

    Do Until Row > 250
    Cells(Row, 1).Select
    Selection.UnMerge
    Cells(Row + 1, 1).Select
    Selection.UnMerge

    If Row + 5 = "" Then
    Row = Row + 8
    Else
    If Row + 6 = "" Then
    Row = Row + 9
    Else
    Row = Row + 5
    End If
    Loop

  2. #2
    Chip Pearson
    Guest

    Re: Compile error: Loop WIthout Do

    You will also get this error when you are missing an End If or
    End With. In your case, you're missing an End If immediately
    before the final Loop statement.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "darin kelberlau" <[email protected]> wrote in message
    news:[email protected]...
    >I get a compile error: loop without do.
    >
    > My code follows. What is wrong!? I see 2 Do's and 2 Loop's.
    >
    >
    >
    >
    > Cells(1, 1).Select
    > Selection.UnMerge
    > Row = 2
    > Do Until Row > 250
    > If Cells(Row, 1) = " " Then
    > If Cells(Row + 2, 1) = "" Then
    > Cells(Row + 3, 1).Select
    > Selection.UnMerge
    > End If
    > End If
    > Row = Row + 1
    > Loop
    >
    > 'unmerge topic and obj'
    > Row = 3
    >
    > Do Until Row > 250
    > Cells(Row, 1).Select
    > Selection.UnMerge
    > Cells(Row + 1, 1).Select
    > Selection.UnMerge
    >
    > If Row + 5 = "" Then
    > Row = Row + 8
    > Else
    > If Row + 6 = "" Then
    > Row = Row + 9
    > Else
    > Row = Row + 5
    > End If
    > Loop




+ 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