Loop learning

G

Guest

Hiding entire row, if value in cell in column B is Yes.

Private Sub CAT()
Dim i As Long

For i = 1 To 25
If Cells(i, 2).Value = "Yes" Then
Rows(i).EntireRow.Hidden = True
End If
Next i
End Sub

Instead of using i = 1 to 25, can't I use the Count property? How would I do
that?
 
G

Guest

Something like this:

Private Sub CAT()
Dim i As Long

For i = 1 To Activesheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
If Cells(i, 2).Value = "Yes" Then
Rows(i).EntireRow.Hidden = True
End If
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

unhide all rows without loop 2
Add Information Box to Macro 4
Easy loop 2
Help needed editing a script 4
VBA group the number in the Column and Copy to the new worksheet. 0
LastCell 5
Hiding rows 2
macro 2

Top