View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Command Button to Hide/Unhide Rows

So you always want rows 6:19, 21:34, 36:49 hidden?

And see 4, 5, 20, 35, 50 when you click a button?

Option Explicit
Private Sub CommandButton1_Click()
Dim myRng As Range
Dim IsHidden As Boolean

Set myRng = Me.Range("a4, a5, a20, a35, a50")
IsHidden = myRng(1).EntireRow.Hidden
Me.Range("a4:a50").EntireRow.Hidden = True
myRng.EntireRow.Hidden = Not (IsHidden)
End Sub



Bea wrote:

In a MS discussion board a few months ago, someone helped me with the
macro listed below. It has worked like a charm and I have been able to
replicate it for different workbooks. I am now stuck again though.

I need to expand only the rows listed (a4, a5, a20, a35, a50) but
collapse all rows within the range(a4:a50). How can I accomplish this?


"Dim myRng As Range

Set myRng = Me.Range("a4, a5, a20, a35, a50")
myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden"

--
Bea
------------------------------------------------------------------------
Bea's Profile: http://www.excelforum.com/member.php...o&userid=32500
View this thread: http://www.excelforum.com/showthread...hreadid=522901


--

Dave Peterson