ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hiding Rows (https://www.excelbanter.com/excel-programming/309471-hiding-rows.html)

~Danny~

Hiding Rows
 
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

Ron de Bruin

Hiding Rows
 
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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"~Danny~" wrote in message ...
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




Tom Ogilvy

Hiding Rows
 
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.

--
Regards,
Tom Ogilvy

"~Danny~" wrote in message
...
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




IC[_2_]

Hiding Rows
 
You may also need to unprotect/protect the sheet.

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

Ian

"Ron de Bruin" wrote in message
...
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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"~Danny~" wrote in message

...
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






Ron de Bruin

Hiding Rows
 
The sheet is protected, userinterfaceonly:= true

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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"IC" wrote in message ...
You may also need to unprotect/protect the sheet.

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

Ian

"Ron de Bruin" wrote in message
...
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


--
Regards Ron de Bruin
http://www.rondebruin.nl


"~Danny~" wrote in message

...
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









All times are GMT +1. The time now is 03:41 AM.

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