Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error Loop without Do 1

Status
Not open for further replies.

sazi22

Technical User
Oct 7, 2004
43
0
0
US
Why am I getting this error when I have "Do" in the code?


Sub Issue()
Range("A2").Select
Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
If ActiveCell = "" Then
Selection.EntireRow.Hidden = True
Loop
End If
End Sub
 
The sequence

[tt]Do While ActiveCell.Value <> ""
ActiveCell.Offset(1, 0).Select
If ActiveCell = "" Then
Selection.EntireRow.Hidden = True
End If
Loop[/tt]

Roy-Vidar
 
Yup - any attempt to finish a loop (either DO, While or Next) within an IF or a WITH block will give this error. WITHS and IFS should be either entirely INSIDE or entirely OUTSIDE any loop

Rgds, Geoff

"Three things are certain: Death, taxes and lost data. Guess which has occurred"

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top