Hi,
I have the following code that works fine except cells that I want "locked" are not locked. I can't find the "select unlocked cells" property as I'm a novice. How do you perform this with VBA code in Excel 2010? Cell A1 is the date being pulled from Worksheets(2) and I don't want the user to be able to change it when they run the pivot table report.

Any help will be appreciated Thanks!


Sub RefreshMonthlySummaryPivotTables()
    Dim Pi As PivotItem

    Worksheets(3).Unprotect "pass"
    Application.ScreenUpdating = False
    
    With ActiveSheet.PivotTables("PivotTable1").PivotFields("Level")

        For Each Pi In .PivotItems
            If Pi.value = "1" Or Pi.value = "1-P" Or Pi.value = "1-HI" Or Pi.value = "2" Or Pi.value = "3" Or Pi.value = "4" Or Pi.value = "X" Or Pi.value = "X-OS" Or Pi.value = "X-TM" Then
                Pi.Visible = True
            Else
                Pi.Visible = False
            End If
        Next Pi
    End With
    
    Application.ScreenUpdating = True
    ActiveSheet.PivotTables("PivotTable1").RefreshTable
              
    Worksheets(3).Protect "pass", AllowFiltering = True, AllowUsingPivotTables = True
    
End Sub