• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Unprotect a slicer

snocaps

New Member
I have a workbook with a pivot table on one sheet (Pivot Budget), and a form with the "getpivottable" data on another sheet (Completed Budget). I have created a slicer for the pivot table and placed the slicer on the sheet with the form. All was well & good until I protected the sheet with the form. I used
Code:
With Worksheets("Completed Budget")
    .Protect Password:="BB", userinterfaceonly:=True
    .EnableOutlining = True
End With
so that I could (successfully) use a button to update the form, but this code does not allow me to select the fields in the slicer.

Any ideas?
 
When you right click on the slicer and select properties, there should be a check box indicating whether the slicer is 'locked' -- when I 'un-check' the box, I am able to change a slicer on a protected sheet.

If the pivot table is on the protected sheet, you have a different problem...
 
Now I have a really weird problem with the password. I have a command button that unprotects the sheet, hides some rows then protects the sheet again. However, when I use the password in any other sub, or even try to enter it manually, Excel tells me my password is incorrect! Any suggestions to fix this?
Code:
Private Sub CommandButton1_Click()

Dim iRow As Long
Dim i As Integer

On Error Resume Next
Application.ScreenUpdating = False
Application.EnableEvents = False
ActiveSheet.Unprotect Password = "BB"

'for each row, if the account has 0's in all columns
'hide the row. cleans up the view.
iRow = Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Cells.EntireRow.Hidden = False

For i = 3 To iRow
If Trim(Range("A" & i)) <> "" Then
    If Range("B" & i) = 0 Then
        If Range("C" & i) = 0 Then
            If Range("D" & i) = 0 Then
                If Range("E" & i) = 0 Then
                    Range("E" & i).EntireRow.Hidden = True
                End If
            End If
        End If
    End If
End If
Next i

ActiveSheet.Outline.ShowLevels RowLevels:=1

ActiveSheet.Protect Password = "BB"
Application.EnableEvents = True
Application.ScreenUpdating = True

'Reset the last cell

ActiveSheet.UsedRange

End Sub

Private Sub Worksheet_Activate()

'Allow user to use button and outline but nothing else

With Worksheets("Completed Budget")
    .Protect Password:="BB", userinterfaceonly:=True
    .EnableOutlining = True
End With


End Sub
 
I think this line of your code...

Code:
ActiveSheet.Protect Password = "BB"

should instead be:

Code:
ActiveSheet.Protect Password:= "BB"

See if that fixes anything.
 
Back
Top