PivotTable Settings Options?

DougStroud

Well-known Member
Joined
Aug 16, 2005
Messages
2,968
Under PivotTable Fields, Subtotal, there are three options, Automatic, Custom and None. Automatic is the default setting, can the defalut setting be changed to None?

And upon creating a new PivotTable, I need to bring every field into the PivotTable from the field list, and there a quite a few. Can multiple fields be selected and populate the PivotTable?

thanks,

doug
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi,
As far as I know, you cannot change the subtotal default setting.

There is an Excel add-in for Pivot Tables, around here somewhere which can be used to set subtotals to none quickly, might be worth a try.

I have never tried adding more than one data field into the pivot table at time. I would be interested to hear of anyone that has done this.

Regards
Mark
 
Upvote 0
I looked up a couple of the add-ins for Excel but did not locate any that would allow to alter the setting from Automatic to None.

Thanks for the reply.

Doug
 
Upvote 0
Hi,

I took this out of an Excel add in, it might be of use to you.

Now you need to do the following in your personal.xls file if you want it available for every worksheet otherwise you need to do the following for any given worksheet.

Not sure how useful this is to you but here goes.

View code and Add 3 new modules.
In one of the modules add the following code:
Code:
Sub HideAllSubtotals()
Dim pt As PivotTable
Dim pf As PivotField
Dim ws As Worksheet
Set ws = ActiveSheet
Dim bPTBar As Boolean
Dim iPTBarPos As Integer
On Error GoTo errHandler

iPTBarPos = Application.CommandBars("PivotTable").Position

bPTBar = Application.CommandBars("PivotTable").Visible

If PivotCheck(ws) Then
  On Error Resume Next
  Application.ScreenUpdating = False
  For Each pt In ActiveSheet.PivotTables
    pt.ManualUpdate = True
    For Each pf In pt.PivotFields
      pf.Subtotals(1) = True
      pf.Subtotals(1) = False
    Next pf
    pt.ManualUpdate = False
  Next pt
Else
  MsgBox "There are no pivot tables on the active sheet"
End If

exitHandler:
  Set pf = Nothing
  Set pt = Nothing
  Set ws = Nothing
  Application.ScreenUpdating = True
  Application.CommandBars("PivotTable").Visible = bPTBar
  Application.CommandBars("PivotTable").Position = iPTBarPos
  Exit Sub

errHandler:
  GoTo exitHandler
End Sub
In the next module add the following code
Code:
Sub ShowAllSubtotals()
Dim pt As PivotTable
Dim pf As PivotField
Dim ws As Worksheet
Dim bPTBar As Boolean
Dim iPTBarPos As Integer
On Error GoTo errHandler

iPTBarPos = Application.CommandBars("PivotTable").Position

bPTBar = Application.CommandBars("PivotTable").Visible
Set ws = ActiveSheet

If PivotCheck(ws) Then
  On Error Resume Next
  Application.ScreenUpdating = False
  For Each pt In ActiveSheet.PivotTables
    pt.ManualUpdate = True
    For Each pf In pt.PivotFields
      pf.Subtotals(1) = True
    Next pf
    pt.ManualUpdate = False
  Next pt
Else
  MsgBox "There are no pivot tables on the active sheet"
End If

exitHandler:
  Set pf = Nothing
  Set pt = Nothing
  Set ws = Nothing
  Application.ScreenUpdating = True
  Application.CommandBars("PivotTable").Visible = bPTBar
  Application.CommandBars("PivotTable").Position = iPTBarPos
  Exit Sub

errHandler:
  GoTo exitHandler
End Sub
In the last module add the following code
Code:
Option Explicit

Public strProcedure As String

Function PivotCheck(ws As Worksheet) As Boolean
  
  PivotCheck = False
  
  If ws.PivotTables.Count > 0 Then
    PivotCheck = True
  End If
  
End Function
You will now have two macros at your finger tips. You should be able to add the macro hideallsubtotals and the macro showallsubtotals to buttons which you can add to one of your tool bars.
No worries if this is no good as I liked playing around to get this to work anyway.

Regards
Mark
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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