Hiding Rows

  • Thread starter Thread starter ~Danny~
  • Start date Start date
D

~Danny~

I'd like to have a toggle button on a sheet that
alternately hides and unhides a number of rows, say 5:10
Anyone know how?
I keep getting the error "Unable to set the Hidden
property of the range class"

The sheet is protected, userinterfaceonly:= true and
enableselection = xlunlocked cells

Many thanks
 
Try this

Sub test()
With ActiveSheet
If .Rows("5:10").EntireRow.Hidden = True Then
.Rows("5:10").EntireRow.Hidden = False
Else
.Rows("5:10").EntireRow.Hidden = True
End If
End With
End Sub
 
Private Sub CommandButton1_Click()
Me.Protect UserInterfaceOnly:=True
Me.EnableSelection = xlUnlockedCells
Rows("5:10").Hidden = Not Rows("5:10").Hidden
End Sub

worked fine for me in Excel 2000. If you have Excel 97, change the
takefocusonclick property to false.
 
You may also need to unprotect/protect the sheet.

Sub test()
Worksheets(1).Unprotect
' Ron's code
Worksheets(1).Protect
End Sub

Ian
 
The sheet is protected, userinterfaceonly:= true

The OP already protect it with userinterfaceonly:= true
The macro should run correct
 

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