Des1gn1ng0ne
Board Regular
- Joined
- Jul 10, 2008
- Messages
- 73
The theory:
Use one unlocked cell, that is limited to a validation list, to control which location (the first row item in the pivot table) is shown. This will allow the sheet to be locked, the location to be changed by any user, and no ability to tamper with the pivot table.
This is a modification of Greg Truby's code on: http://www.mrexcel.com/forum/showthread.php?t=278095
"pi.Visible = False" keeps coming up yellow. Any ideas or am I totally off?
Thanks for any and all help!
Brian S
Use one unlocked cell, that is limited to a validation list, to control which location (the first row item in the pivot table) is shown. This will allow the sheet to be locked, the location to be changed by any user, and no ability to tamper with the pivot table.
This is a modification of Greg Truby's code on: http://www.mrexcel.com/forum/showthread.php?t=278095
"pi.Visible = False" keeps coming up yellow. Any ideas or am I totally off?
Thanks for any and all help!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pt As PivotTable, pf As PivotField, pi As PivotItem
Dim B As String
B = Target.Cells(1, 1)
Set pt = Sheets("Location Total").PivotTables("Contact_Total")
Set pf = pt.PivotFields("BMD")
pt.PivotCache.Refresh
For Each pi In pf.PivotItems
Select Case pi.Name
Case "B"
pi.Visible = True
Case Else
pi.Visible = False
End Select
Next pi
Set pf = Nothing
Set pt = Nothing
End Sub
Brian S