steveuk87
Board Regular
- Joined
- Nov 25, 2013
- Messages
- 78
Hi Guys,
I have a sheet (protected with password) and i need the filter on a PT to change depending on what is selected in a pick list... (see code below)
This works great... when the sheet is unprotected, but i cant get it to unprotect at all, it will lock itself though which i thought was odd, so it's obviously running the later code first. Can anyone help?
I have a sheet (protected with password) and i need the filter on a PT to change depending on what is selected in a pick list... (see code below)
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B37")) Is Nothing Then Exit Sub
Worksheets("Reports").Unprotect Password:="excelace"
Dim pt As PivotTable
Dim Field As PivotField
Dim NewProg As String
Set pt = Worksheets("Reports").PivotTables("PivotTable2")
Set Field = pt.PivotFields("Programme")
NewProg = Worksheets("Reports").Range("B37").Value
With pt
Field.ClearAllFilters
Field.CurrentPage = NewProg
pt.RefreshTable
End With
Worksheets("Reports").Protect Password:="excelace"
End Sub
This works great... when the sheet is unprotected, but i cant get it to unprotect at all, it will lock itself though which i thought was odd, so it's obviously running the later code first. Can anyone help?