TonicQauke
TonicQauke

Reputation: 21

VBA Pivot tables expand

I'm trying to expand the column 'TheyYear' on the pivot tables in all worksheets looping through the the workbook.

Current I have:

For Each ws In ThisWorkbook.Worksheets
                For Each Pt In ws.PivotTables
                  Set Pf = pt.PivotField("[Report vwDimDate].[TheYear].[TheYear]")
                  Pf.ShowDetail = True
                Next
            Next

but it unfortunately doesnt work, I get a runtime error 438 Object doesnt support this property method, can someone please help me on this.

Thank you.

Upvotes: 0

Views: 615

Answers (1)

TonicQauke
TonicQauke

Reputation: 21

I managed to get it to work, I adjusted the VBA to this:

For Each ws In ThisWorkbook.Worksheets
    For Each Pt In ws.PivotTables
        Pt.PivotFields("[Report vwDimDate].[TheYear].[TheYear]").DrilledDown = True   
    Next Pt
Next ws

Upvotes: 1

Related Questions