Unable to set the Visible property of the PivotItem class when setting PivotItem.Visible = false
<p>I want to make <code>PivotItem.Visible = False</code> but I keep getting an error:</p>

<blockquote>
  <p>Unable to set the Visible property of the PivotItem class</p>
</blockquote>

<p>I tried all the solutions I found in the internet but none seems to work </p>

<pre><code>Sub FloorCompareSetter()

    Dim pt As PivotTable
    Dim pf As PivotField
    Dim pi As PivotItem
    Dim PivotSheet As Worksheet

    Set PivotSheet = ThisWorkbook.Worksheets("PIVOT")
    PivotSheet.PivotTables("PivotTable5").RefreshTable

    Set pt = PivotSheet.PivotTables("PivotTable5")
    pt.PivotCache.MissingItemsLimit = xlMissingItemsNone

    Set pf = pt.PivotFields("Period")

    For Each pi In _
        pt.PivotFields("Period").PivotItems
        Select Case pi.Name
            Case Is = "1601A"
                pi.Visible = True
            Case Else
                pi.Visible = False 'error
        End Select
    Next pi

End Sub
</code></pre>

<p>I tried refreshing the table and this line but still not working:</p>

<blockquote>
  <p>pt.PivotCache.MissingItemsLimit = xlMissingItemsNone</p>
</blockquote>

<p>Here is a picture of my pivot table:</p>

<p><a href="https://i.stack.imgur.com/mNJ0X.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mNJ0X.jpg" alt="enter image description here"></a></p>

<p>What am i doing wrong and how can I solve this problem ?</p>