Hi
I'm trying to get HiddenItemsList to work in my OLAP pivot table
I have a list of a few thousand products. First I needed to select the top 500 of these (I got the code to work for this).
Now I need to select everything except the top 500 - this is where things have got tricky.
My code to choose the top 500 - this works fine
Dim myArray() As Variant
Dim myR As Range
Set myR = Range("Prod_Range")
ReDim myArray(0 To myR.Cells.Count - 1)
'Populate array
For i = 0 To myR.Cells.Count - 1
myArray(i) = "[Product].[Product Code Description].[" & myR.Cells(i + 1).Value & "]"
Next i
ActiveSheet.PivotTables("PivotTable1").PivotFields("[Product].[Product Code Description]. _
[Product Code Description]").VisibleItemsList = myArray
But when I try to do the same thing but with HiddenItemsList I get run-time error 1004: Application-defined or object-defined error
Same code as above but with the line below swapped out for the last line (VisibleItemsLIst line)
ActiveSheet.PivotTables("PivotTable2").PivotFields("[Product].[Product Code Description]. _
[Product Code Description]").HiddenItemsList = myArray
I read somewhere I need to set IncludeNewItemsInFilter - I added this line just above the HiddenItemsList line but I just got another error. First time I've used this field so my syntax might not be right, or this might not be the right solution...
ActiveSheet.PivotTables("PivotTable2").PivotFields("[Product].[Product Code Description]. _
[Product Code Description]").IncludeNewItemsInFilter = True
Any suggestions on getting HIddenItemsList to work?
Thanks
I'm trying to get HiddenItemsList to work in my OLAP pivot table
I have a list of a few thousand products. First I needed to select the top 500 of these (I got the code to work for this).
Now I need to select everything except the top 500 - this is where things have got tricky.
My code to choose the top 500 - this works fine
Dim myArray() As Variant
Dim myR As Range
Set myR = Range("Prod_Range")
ReDim myArray(0 To myR.Cells.Count - 1)
'Populate array
For i = 0 To myR.Cells.Count - 1
myArray(i) = "[Product].[Product Code Description].[" & myR.Cells(i + 1).Value & "]"
Next i
ActiveSheet.PivotTables("PivotTable1").PivotFields("[Product].[Product Code Description]. _
[Product Code Description]").VisibleItemsList = myArray
But when I try to do the same thing but with HiddenItemsList I get run-time error 1004: Application-defined or object-defined error
Same code as above but with the line below swapped out for the last line (VisibleItemsLIst line)
ActiveSheet.PivotTables("PivotTable2").PivotFields("[Product].[Product Code Description]. _
[Product Code Description]").HiddenItemsList = myArray
I read somewhere I need to set IncludeNewItemsInFilter - I added this line just above the HiddenItemsList line but I just got another error. First time I've used this field so my syntax might not be right, or this might not be the right solution...
ActiveSheet.PivotTables("PivotTable2").PivotFields("[Product].[Product Code Description]. _
[Product Code Description]").IncludeNewItemsInFilter = True
Any suggestions on getting HIddenItemsList to work?
Thanks