Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88030

Hiding Rows on Another Sheet in a Protected Workbook

$
0
0

I have a workbook with a sort of Table of Contents on Sheet2 with ActiveX checkboxes.

If a user selects one of these checkboxes, it will hide that section on another sheet.

I need this to be a protected workbook.

When I click a checkbox, I receive this error:

"The cell or chart you're trying to change is on a protected sheet. To make changes, click Unprotect Sheet in the Review tab."

Code to protect the workbook:

Private Sub Workbook_Open()
Dim wSheetName As Worksheet
For Each wSheetName In Worksheets
    wSheetName.Protect Password:="pass", UserInterfaceOnly:=True
Next wSheetName
End Sub

The code for the checkbox:

Private Sub CheckBox1_Click()
Application.ScreenUpdating = False

If CheckBox1.Value = True Then
    Sheet1.Rows("4:9").EntireRow.Hidden = True
Else:
    Sheet1.Rows("4:9").EntireRow.Hidden = False
End If

Application.ScreenUpdating = True
End Sub

Viewing all articles
Browse latest Browse all 88030

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>