ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile error: Loop WIthout Do (https://www.excelbanter.com/excel-programming/345979-compile-error-loop-without-do.html)

darin kelberlau

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

Chip Pearson

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" wrote in message
. ..
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





All times are GMT +1. The time now is 01:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com