Hi,
I was able to create some code that will create an array and filter the OLAP field with the list of items in the array. However I have not found a solution to exclude items which are not in the field. I am getting the 1004 Error "The item could not be found in the OLAP Cube".
I have tried searching for solution but haven't really found a simple answer for the code to exclude items that don't exist. Below is the code I'm using to populate the array and filter on OLAP. Any help on fixing the error would be greatly appreciated!
Thanks,
Dan
I was able to create some code that will create an array and filter the OLAP field with the list of items in the array. However I have not found a solution to exclude items which are not in the field. I am getting the 1004 Error "The item could not be found in the OLAP Cube".
I have tried searching for solution but haven't really found a simple answer for the code to exclude items that don't exist. Below is the code I'm using to populate the array and filter on OLAP. Any help on fixing the error would be greatly appreciated!
Thanks,
Dan
Code:
Sub OLAP_Filter2()
Dim myArray() As Variant
Dim myR As Range
Set myR = Sheets(13).Range("A6", Sheets(13).Range("A6").End(xlDown))
ReDim myArray(0 To myR.Cells.Count - 1)
'Populate the array
For i = 0 To myR.Cells.Count - 1
myArray(i) = "[Product].[SKU Nbr].&[" & myR.Cells(i + 1).Value & "]"
Next i
ThisWorkbook.Sheets("OLAP").PivotTables("PivotTable5").PivotFields( _
"[Product].[SKU Nbr].[SKU Nbr]").VisibleItemsList = myArray
End Sub