ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide a sequence of rows (https://www.excelbanter.com/excel-programming/318462-hide-sequence-rows.html)

Dominique Feteau[_2_]

Hide a sequence of rows
 
I would like to hide a sequence of rows. I would run the macro and rows
2-26 would be hidden. I would like to run the macro again a week later and
hide the next 25 rows.

How do i do that?

dominique



Bernie Deitrick

Hide a sequence of rows
 
Dominique,

You can do it by keeping a record of what needs to be hidden in another
cell. For example, if Z1 is currently blank, try the macro below. Of
course, you can change the Z1 to any cell you want.

HTH,
Bernie
MS Excel MVP

Sub DomHideRows()
Dim myRec As Range

Set myRec = Range("Z1")

If myRec.Value = "" Then
myRec.Value = "'27:51"
Range("2:26").EntireRow.Hidden = True
Else
Range(myRec.Value).EntireRow.Hidden = True
myRec.Value = "'" & Range(myRec.Value).Offset(25).Address
End If

End Sub



"Dominique Feteau" wrote in message
...
I would like to hide a sequence of rows. I would run the macro and rows
2-26 would be hidden. I would like to run the macro again a week later

and
hide the next 25 rows.

How do i do that?

dominique





gocush[_28_]

Hide a sequence of rows
 
Bernie can you tell me more about the single quote
in the line:
----------------------------------
myRec.Value = "'27:51"
---------------------------------
Thanks

"Bernie Deitrick" wrote:

Dominique,

You can do it by keeping a record of what needs to be hidden in another
cell. For example, if Z1 is currently blank, try the macro below. Of
course, you can change the Z1 to any cell you want.

HTH,
Bernie
MS Excel MVP

Sub DomHideRows()
Dim myRec As Range

Set myRec = Range("Z1")

If myRec.Value = "" Then
myRec.Value = "'27:51"
Range("2:26").EntireRow.Hidden = True
Else
Range(myRec.Value).EntireRow.Hidden = True
myRec.Value = "'" & Range(myRec.Value).Offset(25).Address
End If

End Sub



"Dominique Feteau" wrote in message
...
I would like to hide a sequence of rows. I would run the macro and rows
2-26 would be hidden. I would like to run the macro again a week later

and
hide the next 25 rows.

How do i do that?

dominique






Bernie Deitrick

Hide a sequence of rows
 
gocush,

The single quote simply prevents Excel from trying to interpret the row
addresses as a time, and ensures that it is entered as text. I could have
used another line to format the storage cell as text, but that's extra code
that is unnecessary....

HTH,
Bernie
MS Excel MVP

"gocush" wrote in message
...
Bernie can you tell me more about the single quote
in the line:
----------------------------------
myRec.Value = "'27:51"
---------------------------------
Thanks

"Bernie Deitrick" wrote:

Dominique,

You can do it by keeping a record of what needs to be hidden in another
cell. For example, if Z1 is currently blank, try the macro below. Of
course, you can change the Z1 to any cell you want.

HTH,
Bernie
MS Excel MVP

Sub DomHideRows()
Dim myRec As Range

Set myRec = Range("Z1")

If myRec.Value = "" Then
myRec.Value = "'27:51"
Range("2:26").EntireRow.Hidden = True
Else
Range(myRec.Value).EntireRow.Hidden = True
myRec.Value = "'" & Range(myRec.Value).Offset(25).Address
End If

End Sub



"Dominique Feteau" wrote in message
...
I would like to hide a sequence of rows. I would run the macro and

rows
2-26 would be hidden. I would like to run the macro again a week

later
and
hide the next 25 rows.

How do i do that?

dominique









All times are GMT +1. The time now is 01:42 PM.

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