Bob Hustead
New Member
- Joined
- Jul 20, 2007
- Messages
- 10
Hello,
This is actually part of a previous thread, but I wanted to try and explain the issue better than I have.
I have cells protected in a sheet and unprotected cells. I also have buttons to toggle rows and columns. The buttons were not functioning properly due to the protection. To overcome this, the following code is inserted in the button modules-this is the entire module code:
Sub ToggleHideB()
ActiveSheet.Unprotect "Pass"
With ActiveSheet.Buttons(2)
If .Caption = "Make C thru F visible" Then
Range("C:F").EntireColumn.Hidden = False
.Caption = "Hide C thru F"
Else
Range("C:F").EntireColumn.Hidden = False
Range("C:F").EntireColumn.Hidden = True
.Caption = "Make C thru F visible"
End If
ActiveSheet.Protect "Pass"
Application.ScreenUpdating = True
End With
End Sub
This works like a charm. The problem is that when I click one of the buttons, my unprotected cells partially revert to protected cells. I am unable to highlight the cell or add comments.
By the way, I have 2002 version of Excel with expanded protection.
I have added code to overcome this. I have tried it in the sheet code and in the workbook code. This is the code:
Private Sub NoRestriction()
ActiveSheet.EnableSelection = xlNoRestriction
End Sub
You have all helped a great deal with this spreadsheet!!!
Thank you,
Bob Hustead
This is actually part of a previous thread, but I wanted to try and explain the issue better than I have.
I have cells protected in a sheet and unprotected cells. I also have buttons to toggle rows and columns. The buttons were not functioning properly due to the protection. To overcome this, the following code is inserted in the button modules-this is the entire module code:
Sub ToggleHideB()
ActiveSheet.Unprotect "Pass"
With ActiveSheet.Buttons(2)
If .Caption = "Make C thru F visible" Then
Range("C:F").EntireColumn.Hidden = False
.Caption = "Hide C thru F"
Else
Range("C:F").EntireColumn.Hidden = False
Range("C:F").EntireColumn.Hidden = True
.Caption = "Make C thru F visible"
End If
ActiveSheet.Protect "Pass"
Application.ScreenUpdating = True
End With
End Sub
This works like a charm. The problem is that when I click one of the buttons, my unprotected cells partially revert to protected cells. I am unable to highlight the cell or add comments.
By the way, I have 2002 version of Excel with expanded protection.
I have added code to overcome this. I have tried it in the sheet code and in the workbook code. This is the code:
Private Sub NoRestriction()
ActiveSheet.EnableSelection = xlNoRestriction
End Sub
You have all helped a great deal with this spreadsheet!!!
Thank you,
Bob Hustead