Professional Documents
Culture Documents
Turn Off Pivot Subtotals (SOLVED)
Turn Off Pivot Subtotals (SOLVED)
Dachacal, You are member of Excel Help Forum for 1 day(s) now but haven't posted anything
yet. How about introducing yourself to the rest of the users? Click on this message bar if you wish
to make an introduction thread now. If you wish to post a question, please choose the relevant
sub-forum.
Results 1 to 11 of 11
+ Reply to Thread
Turn off Pivot subtotals
07-27-2017, 04:49 PM #1
jomili
Turn off Pivot subtotals
Valued Forum Contributor
Weirdest thing; I've been using the below macro for a couple
Join Date: 12-02-2009 of years with no problem. Today it's still working fine for one
Location: Austin, Tx file, but for another I get an error 1004: "Unable to set the
MS-Off Ver: Excel 2016 Office 365 Subtotals property of the PivotField class" at the area noted
64-Bit below. I can't post the WB because the Pivot is based on a
Posts: 3,400 remote data source and it's privileged information (and
huge). I'd be glad to post an example, but the code works
fine on that data. it fails on the "True" line. Help!
End With
On Error GoTo 0
Set PF = GetBudAcctField(PT)
If Not PF Is Nothing Then
With PF
.Orientation = xlPageField
.Position = 5
End With
End If
With .PivotFields("STRATEGY")
.Orientation = xlPageField
.Position = 5
End With
.ColumnGrand = False
.RowGrand = False
.RepeatAllLabels xlRepeatLabels
.ManualUpdate = False
https://www.excelforum.com/excel-programming-vba-macros/1194634-turn-off-pivot-subtotals.html 1/7
9/26/2020 Turn off Pivot subtotals [SOLVED]
.ManualUpdate False
'Turn off subtotals
For Each PF In .PivotFields
'Set index 1 (Automatic) to True,
'so all other values are set to False
PF.Subtotals(1) = True
PF.Subtotals(1) = False
Next PF
Stop
End With
Exit Sub
Bailout:
MsgBox "The Open Year Summary can't be refreshed rig
"Please try again later.", vbOKOnly + vbInformation,
WbSrc.Close False
SpeedOff
Exit Sub
07-27-2017, 05:09 PM #2
jeffreybrown
Re: Turn off Pivot subtotals
Forum Moderator
I've been using the below macro for a couple of years
with no problem
Join Date: 02-19-2009 I suspect, if its been working for years and the only thing
Location: Cibolo, TX different is a new workbook, then don't you think it's the
MS-Off Ver: Excel 2016 workbook and not the code?
Posts: 10,052
If we can't see the workbook (and understandable why), then
it's going to be hard to diagnose any problem.
HTH
Regards, Jeff
07-27-2017, 05:38 PM #3
MarvinP
Re: Turn off Pivot subtotals
Forum Guru
Hey,
https://www.excelforum.com/excel-programming-vba-macros/1194634-turn-off-pivot-subtotals.html 2/7
9/26/2020 Turn off Pivot subtotals [SOLVED]
Location: Woodinville, WA names has changed. Do it by hand and see what changed
MS-Off Ver: Office 365 from the last time you did it.
Posts: 15,249
07-28-2017, 07:20 AM #4
jomili
Re: Turn off Pivot subtotals
Valued Forum Contributor
Good suggestion, but no joy. If I stop the macro right before
Join Date: 12-02-2009 the "Subtotals" set, then manually go to Design/Subtotals/Do
Location: Austin, Tx Not Show subtotals it works just fine. But if I try the macro to
MS-Off Ver: Excel 2016 Office 365 turn off the subtotals I get the error.
64-Bit
Posts: 3,400 Just tried it this morning again, by isolating the "subtotal"
part of the macro (see code below). Opened WB, made no
changes to the Pivot, manually turned off subtotals,
everything's great. Closed without saving. Reopened, ran
macro below. Error.
Sub Filter_Pivot()
Dim PF As PivotField
Dim PI As PivotItem
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables(1)
SpeedOn
With PT
'Turn off subtotals
For Each PF In .PivotFields
'Set index 1 (Automatic) to True,
'so all other values are set to False
PF.Subtotals(1) = True
PF.Subtotals(1) = False
Next PF
End With
SpeedOff
End Sub
https://www.excelforum.com/excel-programming-vba-macros/1194634-turn-off-pivot-subtotals.html 3/7
9/26/2020 Turn off Pivot subtotals [SOLVED]
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
E bl E t T
Attached Images
Problem Piv.PNG (59.0 KB, 38 views)
Download
Trouble Free Piv.PNG (59.3 KB, 39 views)
Download
07-28-2017, 07:36 AM #5
xlnitwit
Re: Turn off Pivot subtotals
Forum Guru
Since setting it to True fails, why not use
Application.CommandBars.ExecuteMso "PivotTableSubtota
Don
Please remember to mark your thread 'Solved' when appropriate.
07-28-2017, 07:50 AM #6
jomili
Re: Turn off Pivot subtotals
Valued Forum Contributor
Tried the first option like this, got the same error:
Join Date: 12-02-2009
Location: Austin, Tx
MS-Off Ver: Excel 2016 Office 365 Sub Filter_Pivot()
Dim PF As PivotField
64-Bit
Dim PI As PivotItem
Posts: 3,400 Dim PT As PivotTable
https://www.excelforum.com/excel-programming-vba-macros/1194634-turn-off-pivot-subtotals.html 4/7
9/26/2020 Turn off Pivot subtotals [SOLVED]
Set PT = ActiveSheet.PivotTables(1)
SpeedOn
With PT
'Turn off subtotals
For Each PF In .PivotFields
PF.Subtotals = Array(False, False, False, Fa
'Set index 1 (Automatic) to True,
'so all other values are set to False
' PF.Subtotals(1) = True
' PF.Subtotals(1) = False
Next PF
End With
SpeedOff
End Sub
Trying this, it works. But why won't the other two work?
Sub Filter_Pivot()
Dim PF As PivotField
Dim PI As PivotItem
Dim PT As PivotTable
Set PT = ActiveSheet.PivotTables(1)
SpeedOn
ActiveSheet.Range("A5").Select
With PT
'Turn off subtotals
Application.CommandBars.ExecuteMso "PivotTableSubtota
' For Each PF In .PivotFields
' PF.Subtotals = Array(False, False, False, Fa
'Set index 1 (Automatic) to True,
'so all other values are set to False
' PF.Subtotals(1) = True
' PF.Subtotals(1) = False
' Next PF
End With
SpeedOff
End Sub
08-21-2019, 02:03 AM #7
pete22k
Re: Turn off Pivot subtotals
Registered User
when i tried the second option which has the following code
Join Date: 08-21-2019 for Pivot Table donot show subtotals
Location: AZ,USA
MS-Off Ver: 2013
Posts: 3
Application.CommandBars.ExecuteMso "PivotTableSubtota
08-21-2019, 04:14 AM #8
https://www.excelforum.com/excel-programming-vba-macros/1194634-turn-off-pivot-subtotals.html 5/7
9/26/2020 Turn off Pivot subtotals [SOLVED]
rorya
Re: Turn off Pivot subtotals
Forum Expert
Did you select a cell in the pivot table first, as xlnitwit
mentioned?
Rory
Yea though I walk through the valley of the shadow of death, at least
it's a change of scenery
Report Post Reply With Quote
08-21-2019, 10:18 AM #9
pete22k
Re: Turn off Pivot subtotals
Registered User
yes i did select pivot table it begins from cell 23, not sure of
Join Date: 08-21-2019 xlnitwit method
Location: AZ,USA
MS-Off Ver: 2013
Posts: 3
wrkSht.Range("B23").Select
On Error Resume Next
Set pt = wrkSht.PivotTables("PivotTable1")
On Error GoTo 0
jomili
Re: Turn off Pivot subtotals
Valued Forum Contributor
pete22k, can you upload a copy of your pivot workbook so we
Join Date: 12-02-2009 can take a look?
Location: Austin, Tx
MS-Off Ver: Excel 2016 Office 365
64-Bit
Posts: 3,400
pete22k
Re: Turn off Pivot subtotals
https://www.excelforum.com/excel-programming-vba-macros/1194634-turn-off-pivot-subtotals.html 6/7
9/26/2020 Turn off Pivot subtotals [SOLVED]
Registered User
This solution is working fine, i was getting error this place due
Join Date: 08-21-2019 to wrong placement of code. Thanks to xlnitwit who posted
Location: AZ,USA the solution & rorya for giving the pointer
MS-Off Ver: 2013
Posts: 3
+ Reply to Thread
Thread Information
There are currently 1 users browsing this thread. (1 members and 0 guests)
Dachacal
Similar Threads
[SOLVED] VBA code to turn data into pivot table and then into pivot chart Replies: 1
By Faintkitara in forum Excel Programming / VBA / Macros Last Post: 05-25-2015, 08:05 PM
All times are GMT -5. The time now is 06:53 AM.
https://www.excelforum.com/excel-programming-vba-macros/1194634-turn-off-pivot-subtotals.html 7/7