Hide Second Row - Relative (row number changes)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

Should be easy -- I simply want to hide the second row, but that row number
may be two now, three later, and four after that.... How do I get it to not
care about the row number, yet hide the second visible row?

Thanks!
 
Sub BBB()
Dim i As Long, j As Long
i = 0
j = 1
Do Until i >= 2
If Cells(j, 1).EntireRow.Hidden = False Then
If i = 1 Then
Cells(j, 1).EntireRow.Hidden = True
i = i + 1
Exit Do
Else
i = i + 1
End If
End If
j = j + 1
Loop

End Sub

You could also probably use specialcells, but I would need to know more
about what is on your sheet and what you are doing. The above should be
sufficient.
 
Here's one way

Dim i As Long
Dim fVisible As Boolean

For i = 1 To Rows.Count
If Not Rows(i).Hidden Then
If fVisible Then
Rows(i).Hidden = True
Exit For
Else
fVisible = True
End If
End If
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Perfect...... Thanks gentlemen (I'm sure you have better things to do on a
Sunday, if not, could you briefly tell me what some of these commands mean?!)
 

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

Back
Top