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

For starters you need a closing bracket and lose the (1)
myRng.EntireRow.Hidden = Not (myRng.EntireRow.Hidden)

The above line will simply hide and unhide those 5 rows
So this works if A4:A50 is already hidden and dont get altered

You could manually hide A4:A50 the first time or add
Worksheets("Sheet1").Range("A4:A50).EntireRow.Hidd en = True
To the 'Workbook Open' To hide that range every time the book is opened
Replace "Sheet1" with your sheet name

Otherwise you need a different approach

George

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"