Hi All,
I need to build a VisibleItemsList to be able to filter based on the Criteria that the PivotItems names Should begin with DC- but not DC-PLANNING. My idea so far is this:
(I) Build an array of values and
(II) use the array in the .VisibleItmesList
Here is the code I got so far.
Intended list should be able to look like this
Can any please help with this.
Thanks in advance.
I need to build a VisibleItemsList to be able to filter based on the Criteria that the PivotItems names Should begin with DC- but not DC-PLANNING. My idea so far is this:
(I) Build an array of values and
(II) use the array in the .VisibleItmesList
Here is the code I got so far.
Code:
Sub FilterThem()
Dim MyFilterArray() As String
Worksheets("Sheet4").Activate
With Worksheets("Sheet3").PivotTables("PivotTable8")
c = 1
For i = 1 To .PivotFields.Count
r = 1
Cells(r, c) = .PivotFields(i).Name
For x = 1 To .PivotFields(i).PivotItems.Count
If Mid(.PivotFields(i).PivotItems(x).Name, 36, 4) = "[DC-" And Not (Mid(.PivotFields(i).PivotItems(x).Name, 36, 12) = "[DC-PLANNING") Then
ReDim Preserve MyFilterArray(d)
MyFilterArray = .PivotFields(i).PivotItems(x).Name
End If
r = r + 1
Next
c = c + 1
Next
End With
End Sub
Intended list should be able to look like this
Code:
Array( "[CSVFolderPivotTable].[FAIN].&[DC-04-0007]", "[CSVFolderPivotTable].[FAIN].&[DC-04-0008]", "[CSVFolderPivotTable].[FAIN].&[DC-05-0011]", "[CSVFolderPivotTable].[FAIN].&[DC-34-0002]", "[CSVFolderPivotTable].[FAIN].&[DC-44-X001]", "[CSVFolderPivotTable].[FAIN].&[DC-54-0002]", "[CSVFolderPivotTable].[FAIN].&[DC-34-0002]", "", "[CSVFolderPivotTable].[FAIN].&[DC-57-X007]", "", "", "[CSVFolderPivotTable].[FAIN].&[DC-75-0002]", "[CSVFolderPivotTable].[FAIN].&[DC-75-0003]", "[CSVFolderPivotTable].[FAIN].&[DC-75-0004]", "", "", "[CSVFolderPivotTable].[FAIN].&[DC-90-X088]")
Can any please help with this.
Thanks in advance.
Last edited: