Hello,
So I have a spreadsheet where I automatically update a PivotTable with a filter. Basically, it counts the number of brokers that we have a particular security with and then filters out any names where the amount is actually zero. The problem is, the pi.Visible = True line does not work. It causes a "Run-time error '1004': Unable to set the Visible property of the PivotItem class". The pi.Visible = False line works perfectly fine. Can someone please take a look at my code and see if they can get it to work? See below.
Thanks in advance!!!
Todd
So I have a spreadsheet where I automatically update a PivotTable with a filter. Basically, it counts the number of brokers that we have a particular security with and then filters out any names where the amount is actually zero. The problem is, the pi.Visible = True line does not work. It causes a "Run-time error '1004': Unable to set the Visible property of the PivotItem class". The pi.Visible = False line works perfectly fine. Can someone please take a look at my code and see if they can get it to work? See below.
Thanks in advance!!!
Todd
Code:
Sub LoadSecurityList()
Dim IngSortOrder As Long, strSortField As String
Dim pt As PivotTable, pf As PivotField, pi As PivotItem
Set pt = ActiveSheet.PivotTables("PivotTable6")
Set pf = pt.PivotFields("S/D Amount")
pt.PivotCache.Refresh
pt.ManualUpdate = True
pf.EnableMultiplePageItems = True
strSortField = pf.AutoSortField
IngSortOrder = pf.AutoSortOrder
pf.AutoSort xlManual, pf.SourceName
For Each pi In pf.PivotItems
If pi.Visible <> True Then
pi.Visible = True
End If
Next pi
For Each pi In pf.PivotItems
If pi.Value = "0" Then
pi.Visible = False
End If
Next pi
pt.ManualUpdate = False
pf.AutoSort IngSortOrder, strSortField