MultipleItems
が許可されている場合、どの項目がピボットテーブルフィルタでチェックされているかを知ることはできますか?ピボットテーブルで複数のアイテムが選択されているかどうかを確認する方法は?
私はそれを確認するには.Visible
プロパティを参照してくださいが、複数の項目が許可されていない場合にのみ機能します。 複数の項目が許可され、.Visible
プロパティがチェックされている場合は、選択したすべての項目の代わりに「すべて」が表示されます。
これを行う方法は?
Dim pvt As PivotTable
Dim fld As PivotField
Dim itm As PivotItem
Dim flt As PivotFilter
Dim i As Integer
Set xbFuente = ThisWorkbook
Set xlDatos = xbFuente.Worksheets("TABLAS")
Set pvt = xlDatos.PivotTables("MAIN")
pvt.ManualUpdate = True
Application.EnableEvents = False
Application.ScreenUpdating = False
If pvt.ShowPageMultipleItemLabel = True Then
Debug.Print "The words 'Multiple Items' can be displayed."
End If
For Each fld In pvt.PageFields
Debug.Print fld.Name & " -- " & fld.Orientation & " -- " & fld.EnableItemSelection & " -- " & fld.EnableMultiplePageItems & " -- "
If fld.AllItemsVisible = True Then
' If all items are visible "ALL"
For Each itm In fld.VisibleItems
Debug.Print "---- ALLITEMSVISIBLE TRUE --" & "VISIBLE" & " -- " & itm.Name & " -- " & itm.Visible
Next
Else
For Each itm In fld.VisibleItems
Debug.Print "---- ALLITEMSVISIBLE FALSE --" & "VISIBLE" & itm.Name & " -- " & itm.Visible
Next
For Each itm In fld.HiddenItems
Debug.Print "--------ALLITEMSVISIBLE FALSE --" & "HIDDEN -- " & itm.Name & " -- " & itm.Visible
Next
For Each itm In fld.PivotItems
Debug.Print "--------ALLITEMSVISIBLE FALSE --" & "HIDDEN -- " & itm.Name & " -- " & itm.Value
Next
End If
Next
結果: Warranty Flag -- 3 -- Verdadero -- Verdadero -- ---- ALLITEMSVISIBLE FALSE --VISIBLE(All) -- Verdadero --------ALLITEMSVISIBLE FALSE --HIDDEN -- A -- Falso --------ALLITEMSVISIBLE FALSE --HIDDEN -- I -- Falso --------ALLITEMSVISIBLE FALSE --HIDDEN -- O -- Falso --------ALLITEMSVISIBLE FALSE --HIDDEN -- P -- Falso