Loop

laddin
03-25-2003, 09:50 AM
I am trying to a looping function to hide and unhide rows on several worksheets in a workbook. Can anyone help me get the syntax in the right order. Thanks.

Sub rows()

If Range("m3").Value = "yes" Then
i = 2
Do Until i = 14
With Sheets(i)
.rows("9:300").EntireRow.Hidden = True
End With
If ActiveCell.Value = "data" Then
ActiveCell.EntireRow.Hidden = False
End If
i = i + 1
Loop
End If

italkid
03-25-2003, 10:17 AM
In This way it works for me :


Private Sub CommandButton1_Click()
Dim i As Integer

For i = 1 To ActiveWorkbook.Sheets().Count
Next i

If Range("M3").Value = "yes" Then

i = 1
Do Until i = 3
With Sheets(i)
.Rows("9:300").EntireRow.Hidden = True
End With

If ActiveCell.Value = "data" Then
ActiveCell.EntireRow.Hidden = False
End If

i = i + 1
Loop
End If

End Sub


You will have to set the Do Until part back to 14,i only tested it with 3 sheets.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum