achilles18
New Member
- Joined
- May 24, 2015
- Messages
- 20
Hi All,
I am currently using a macro script within my workbook to un-hide hidden rows which I got from here thank you to Rick Rothstein!! It works really well until I try to protect my work sheet and then execute the script.
Here is a copy of the exact code I am using
So to break it down and try to provide enough information. At the start I went through and formatted the cells within the worksheet and locked/un-locked what ever I needed to. I then hid the rows which I didn't want seen. I then went and Protected the worksheet, only allowing "Select Locked Cells and Select Unlocked cells" to be accessed. When doing this and running the macro (via a active x command button) I got the following error "Run-time error '1004': Unable to set the Hidden property of the Range class".
So I unlocked the work sheet and then relocked it allowing "Format Columns, Format rows, Insert Columns and Insert Rows" this time the macro worked, but instead of cycling through and un-hiding row after row it only un-hides one row and that is it.
Any idea why it would only un-hide one row and then stop? It works fine as soon as I un-protect the worksheet again.
Thanks in advance, I hope that was enough info.
Regards
I am currently using a macro script within my workbook to un-hide hidden rows which I got from here thank you to Rick Rothstein!! It works really well until I try to protect my work sheet and then execute the script.
Here is a copy of the exact code I am using
Code:
Private Sub CommandButton1_Click()
'Add Scope
If Rows(42).Hidden Then
Rows(42).Hidden = False
Else
On Error Resume Next
With Range("A41:A59").SpecialCells(xlVisible)
.Areas(1)(.Areas(1).Count).Offset(1).EntireRow.Hidden = False
End With
On Error GoTo 0
End If
End Sub
So to break it down and try to provide enough information. At the start I went through and formatted the cells within the worksheet and locked/un-locked what ever I needed to. I then hid the rows which I didn't want seen. I then went and Protected the worksheet, only allowing "Select Locked Cells and Select Unlocked cells" to be accessed. When doing this and running the macro (via a active x command button) I got the following error "Run-time error '1004': Unable to set the Hidden property of the Range class".
So I unlocked the work sheet and then relocked it allowing "Format Columns, Format rows, Insert Columns and Insert Rows" this time the macro worked, but instead of cycling through and un-hiding row after row it only un-hides one row and that is it.
Any idea why it would only un-hide one row and then stop? It works fine as soon as I un-protect the worksheet again.
Thanks in advance, I hope that was enough info.
Regards