Macro to Show or Export Pivot Table Properties in a Report

dapoole

New Member
Joined
Jul 20, 2004
Messages
22
Hi there,

Is it possible to create a macro that when run will show or export pivot table properties in a report? For example, if you right click on a pivot table cell then select 'Show Properties in Report' you can select items indiviudally. This can take a long time if you have a lot of properties to include. Is it possible to run a macro to show/export these pre-defined properties?

TIA
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
For example, if you right click on a pivot table cell then select 'Show Properties in Report' you can select items indiviudally?


Hi dapoole, What version of Excel are you using? I haven't seen that right-button menu item in Excel 2007 or 2010 (for Windows).

A macro could certainly read PivotTable properties and display them. Which properties do would you want to read?
 
Upvote 0
Hi there,

Thanks for your reply. I am using Excel 2010. The right-click option 'Show Properties in Report' only shows when you appear to be at the root of your raw data. For example I've created a basic pivot table which consists of a count of clients that meet particular report filter values. I then include the 'customer number' into the row labels box. Then when I right click on the customer number on the pivot-table the option 'Show Properties in Report' appears, from which I can include any data from the cube. I just want a macro to show these 'properties' in a report automatically.

Hope that helps you understand.

TIA.
 
Upvote 0
Ah....I didn't realize that you had an OLAP cube data source. I haven't noticed that option when I've used cubes.

There's a 'ShowAll' option after clicking the 'Show Properties in Report' item.
Are you wanting a macro that provides the same result as if the user clicked the 'Show Properties in Report' then 'ShowAll'?

How would you want to trigger the running of that macro?
 
Upvote 0
Thanks again. There are quite a few properties in the cube so the ShowAll is not really an option for me. I'd like to be able to run a macro to show then export a limited number of properties, such as: title, forename, surname, address1, address2, address3, town, county, postcode, country, telno1, ... if you get my drift. I dont mind how the macro is run just as long as it functions. Do you think this is possible?
 
Upvote 0
I'd suggest that you record a macro while you manually display a few of the properties that you want to show. This will give you the correct syntax for referencing the top level rowfield.

When I did this with an example cube, the recorded macro looked like this....

Code:
Sub Macro1()
'
' Macro1 Macro
'
    ActiveSheet.PivotTables("PivotTable2").ManualUpdate = True
    ActiveSheet.PivotTables("PivotTable2").CubeFields( _
        "[Fiscal Periods].[Fiscal Period]").AddMemberPropertyField Property:= _
        "[Fiscal Periods].[Fiscal Period].[Fiscal Period].[Fiscal Month]"
    ActiveSheet.PivotTables("PivotTable2").CubeFields( _
        "[Fiscal Periods].[Fiscal Period]").AddMemberPropertyField Property:= _
        "[Fiscal Periods].[Fiscal Period].[Fiscal Period].[Fiscal Period]"
    ActiveSheet.PivotTables("PivotTable2").ManualUpdate = False
    Range("I11").Select
End Sub

Once you have that syntax, you can substitute the names of your PivotTable, top level RowField, and List of Properties into the code shown below.

Code:
Sub DisplayMyProps()
    Dim vPropsList As Variant
    Dim i As Long

    
    vPropsList = Array("Fiscal Month", "Fiscal Period", "Fiscal Quarter")

    
    With ActiveSheet.PivotTables("PivotTable2")
        .ManualUpdate = True
        With .CubeFields("[Fiscal Periods].[Fiscal Period]")
            For i = LBound(vPropsList) To UBound(vPropsList)
                .AddMemberPropertyField Property:= _
                    "[Fiscal Periods].[Fiscal Period].[Fiscal Period].[" _
                    & vPropsList(i) & "]"
            Next i
        End With
        .ManualUpdate = False
    End With
End Sub

If you want help adapting the code, please post the recorded macro you create while manually displaying a few properties.

Once displayed, what parts of the PivotTable do you want to export and in what format?
Do you just want to take the entire PivotTable report and paste it as values into another workbook, or something else?
 
Upvote 0

Forum statistics

Threads
1,215,018
Messages
6,122,703
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top