CarlAbdelnour
New Member
- Joined
- Jul 19, 2018
- Messages
- 6
Function tableau
Dim fld As PivotField
Dim pitem As PivotItem
Dim i As Long
Dim arr() As Variant
Sheets("PivotTableSheet").Activate
For Each fld In Sheets("PivotTableSheet").PivotTables("PivotTable").PivotFields
If fld.Orientation <> xlHidden And fld.Orientation = xlColumnField Then 'loop through filtered pivot fields
i = 1
For Each pitem In fld.PivotItems 'loop through visible items in filtered pivot fields
If pitem.Visible = True Then
ReDim arr(1 To i) As Variant
arr(i) = pitem
Sheets("Données").ListObjects("table1").Range.AutoFilter Field:=TRVFILTRE(fld.Name), Criteria1:=arr, Operator:=xlFilterValues
i = i + 1
End If
Next pitem
End If
Next fld
End Function
Hello, I would like to know if I can filter a table based on multiple criteria (in a dynamic array)
The function is filtering the table with the last item in the array arr(), I'd like it to filter all the items in the array. TRVFILTRE(fld.name) finds the column of the field name
and returns a number.
It would be great to have a solution
Thank you a lot for the help
Dim fld As PivotField
Dim pitem As PivotItem
Dim i As Long
Dim arr() As Variant
Sheets("PivotTableSheet").Activate
For Each fld In Sheets("PivotTableSheet").PivotTables("PivotTable").PivotFields
If fld.Orientation <> xlHidden And fld.Orientation = xlColumnField Then 'loop through filtered pivot fields
i = 1
For Each pitem In fld.PivotItems 'loop through visible items in filtered pivot fields
If pitem.Visible = True Then
ReDim arr(1 To i) As Variant
arr(i) = pitem
Sheets("Données").ListObjects("table1").Range.AutoFilter Field:=TRVFILTRE(fld.Name), Criteria1:=arr, Operator:=xlFilterValues
i = i + 1
End If
Next pitem
End If
Next fld
End Function
Hello, I would like to know if I can filter a table based on multiple criteria (in a dynamic array)
The function is filtering the table with the last item in the array arr(), I'd like it to filter all the items in the array. TRVFILTRE(fld.name) finds the column of the field name
and returns a number.
It would be great to have a solution
Thank you a lot for the help