ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Do Until Loop Not Working (https://www.excelbanter.com/excel-programming/398463-do-until-loop-not-working.html)

PJFry

Do Until Loop Not Working
 
When I try to compile the code below, I get a 'Loop without Do' error. The
code is designed to loop through an array and hide the rows that have a zero
value.

Thoughts?
Using Excel 2003.


Sub HideRow()

Range("B15").Select

Do Until ActiveCell = "STOP"
If ActiveCell.Value = 0 Then
ActiveCell.EntireRow.Hidden = True
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
Loop

End Sub

JE McGimpsey

Do Until Loop Not Working
 
In article ,
PJFry wrote:

When I try to compile the code below, I get a 'Loop without Do' error. The
code is designed to loop through an array and hide the rows that have a zero
value.

Thoughts?


You need an

End If

before the

Loop

statement.

Tom Ogilvy

Do Until Loop Not Working
 
Sub HideRow()

Range("B15").Select

Do Until ActiveCell = "STOP"
If ActiveCell.Value = 0 Then
ActiveCell.EntireRow.Hidden = True
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End if
Loop

End Sub

--
Regards,
Tom Ogilvy


"PJFry" wrote:

When I try to compile the code below, I get a 'Loop without Do' error. The
code is designed to loop through an array and hide the rows that have a zero
value.

Thoughts?
Using Excel 2003.


Sub HideRow()

Range("B15").Select

Do Until ActiveCell = "STOP"
If ActiveCell.Value = 0 Then
ActiveCell.EntireRow.Hidden = True
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
Loop

End Sub


PJFry

Do Until Loop Not Working
 
Ah! Works perfectly. Thanks!

"JE McGimpsey" wrote:

In article ,
PJFry wrote:

When I try to compile the code below, I get a 'Loop without Do' error. The
code is designed to loop through an array and hide the rows that have a zero
value.

Thoughts?


You need an

End If

before the

Loop

statement.



All times are GMT +1. The time now is 02:07 PM.

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