Pivot Table created in Macro doesn't Refresh

KHaag

New Member
Joined
Jun 1, 2018
Messages
21
I've created a Pivot Table, in a Macro. It isn't doing all of the Sum calculations on creation. When I refresh the Pivot Table manually, it looks like this:
1601719494540.png



The Pivot Table created in the Macro looks like this:
1601719341297.png


My code is:
'add, organize and format Pivot Table fields
VBA Code:
    With myPivotTable
        .PivotFields("Stands::StandTextName").Orientation = xlRowField
        .PivotFields("GradingsSpecies").Orientation = xlRowField
        With .PivotFields("TPA")
            .Orientation = xlDataField
            .Position = 1
            .Function = xlSum
            .NumberFormat = "#,##0.0000000"
        End With
            With .PivotFields("BASAL AREA")
            .Orientation = xlDataField
            .Position = 2
            .Function = xlSum
            .NumberFormat = "#,##0.00"
        End With
       
        'Turn off Grand Totals
         myPivotTable.ColumnGrand = False

    End With
    '
    'Refresh myPivotTable as a precaution
    Range("B7").Select
    ActiveSheet.PivotTables("PivotTableNewSheet").PivotCache.Refresh
 
Last edited by a moderator:

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

KHaag

New Member
Joined
Jun 1, 2018
Messages
21
I believe I have found the answer to my question above. No longer looking for responses.
Thank you
 

Watch MrExcel Video

Forum statistics

Threads
1,114,111
Messages
5,546,005
Members
410,720
Latest member
SSL
Top