View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Zone Zone is offline
external usenet poster
 
Posts: 269
Default Page Protection interfering with Hiding Rows

Private Sub passdeny_Click()
ActiveSheet.Unprotect password:="yourpassword"
DENYPASS
ActiveSheet.Protect password:="yourpassword"
End Sub

James

wrote:
have a sheet that hides groups of rows based on a cell's information.
I'd prefer this to happen automatically through VBA, but currently I'm
stuck using a Toggle Button to hide/unhide these rows.

The problem I run into though is that that toggle button works
brilliantly until I turn on the page protection. Once I turn on the
protection I keep getting errors that the page is protected and can't
be updated.


And due to the fact that the people who will be using this know
absolutely no Excel at all and break formulas on the old sheet
regularly... well, the sheet has to be write-protected.


The code I'm currently using is this:
Sub DENYPASS()


Application.ScreenUpdating = False
Application.EnableEvents = False


If Range("B2") = 1 Then
Rows("11:41").EntireRow.Hidden = True
Rows("42:72").EntireRow.Hidden = False
Else
Rows("11:41").EntireRow.Hidden = False
Rows("42:72").EntireRow.Hidden = True
End If


Application.ScreenUpdating = True
Application.EnableEvents = True


End Sub


with a private sub to connect it to the Toggle Button


Private Sub passdeny_Click()
DENYPASS
End Sub