Domanda

In Excel 2003 I am trying to create a Workbook_SheetPivotTableUpdate Sub that enforces a restriction on a pivot table such that a particular pivot item of a particular row field must never be visible but must still contribute to subtotals and grand totals.

I know there is a setting "Subtotal hidden page items" that allows this to happen if the field is a page field. I also know how I can force the pivot item to be visible or not:

Private Sub Workbook_SheetPivotTableUpdate(ByVal Sh As Object, ByVal Target As PivotTable)
    Dim pvtField As PivotField
    Dim pvtItem As PivotItem
    Set pvtField = Target.PivotFields("Specific Field")
    If pvtField.Orientation = xlRowField Then
        Set pvtItem = pvtField.PivotItems("Specific Item")
        pvtItem.Visible = False
    End If
End Sub

But I don't know if it is possible to put it in a state where the user cannot see it but it continues to contribute to the subtotals and grand totals in the pivot table.

enter image description here

Short of iterating through the rows of the pivot table and setting the row heights to 0, is there a state for pivot items or a way to manipulate the way Excel calculates the totals to accomplish this?

È stato utile?

Soluzione

I'm going to say that the answer is "no".

I had never even noticed the "Subtotal hidden page items" feature that you mentioned. Reading about it, it sounds like this only applies to OLAP cubes, although it's a little unclear if that was true with Excel 2003. (I'm using Excel 2010, where they've changed the name slightly.) Out of curiosity, does the page field setting work for you, and are you using an OLAP cube?

At any rate, I'm sure the best way to do what you're looking for is the set the row's Hidden property to true, as you've already indicated.

Not that you asked, but it seems like this design would be confusing to the user.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top