VBA Code - Pivot - Show all Subtotals at Bottom of Group

NEW_2VBA

Board Regular
Joined
Dec 15, 2015
Messages
106
Hello! Since a recent change in excel the following macro works but appears differently. I'm wondering if there's a way to alter the VBA code to create the Pivot table and show subtotals at bottom of group. Thanks!

Sub CreateInvoicePVT_1()

Dim sht As Worksheet
Dim pvtCache As PivotCache
Dim PVT As PivotTable
Dim StartPvt As String
Dim SrcData As String
SrcData = ActiveSheet.Name & "!" & Range("A1:R50000").Address(ReferenceStyle:=xlR1C1)
Set sht = Sheets.Add
StartPvt = sht.Name & "!" & sht.Range("A3").Address(ReferenceStyle:=xlR1C1)
Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=SrcData)
Set PVT = pvtCache.CreatePivotTable( _
TableDestination:=StartPvt, _
TableName:="PivotTable1")
ActiveCell.Offset(4, 1).Range("A1").Select
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Invoice#")
.Orientation = xlRowField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("RequestAmount"), "Sum of RequestAmount", xlSum
With ActiveSheet.PivotTables("PivotTable1").PivotFields("InvoiceDate")
.Orientation = xlRowField
.Position = 2
End With
ActiveSheet.Name = "INVOICE PIVOT"
End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,215,197
Messages
6,123,585
Members
449,108
Latest member
rache47

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