ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide Second Row - Relative (row number changes) (https://www.excelbanter.com/excel-programming/324171-hide-second-row-relative-row-number-changes.html)

Jeff

Hide Second Row - Relative (row number changes)
 
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!

Tom Ogilvy

Hide Second Row - Relative (row number changes)
 
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.

--
Regards,
Tom Ogilvy




"JEFF" wrote in message
...
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!




Bob Phillips[_6_]

Hide Second Row - Relative (row number changes)
 
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)


"JEFF" wrote in message
...
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!




Jeff

Hide Second Row - Relative (row number changes)
 
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?!)

"Tom Ogilvy" wrote:

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.

--
Regards,
Tom Ogilvy




"JEFF" wrote in message
...
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!






All times are GMT +1. The time now is 11:45 PM.

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