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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

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,323
Messages
5,547,253
Members
410,781
Latest member
fabalshehhi
Top