Is it possible to automate pivot table formatting plz?

Bled

New Member
Joined
Dec 31, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
Hello,

I always always use the same pivot table formating, checking 3 things before using it:

- Repeat item labels

- Show in Tabular Format

- Hide Subtotals

I know 3 clicks doesn't sound time consuming, but when you are working with pivot tables all day it can be.

I tried recording macro , but the result macro take more time than when done manually.

Can this formatting be by default? or is there VBa macro to help with it?

Any help appreciated, thanks
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
684
Office Version
  1. 365
Platform
  1. Windows
Paste the macro that you recorded
 

Bled

New Member
Joined
Dec 31, 2020
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
Paste the macro that you recorded
I just found this macro, does a good job so far, maybe it can help someone:

Sub CleanPivot()

Dim pt As PivotTable
Dim pf As PivotField

On Error Resume Next
Set pt = ActiveCell.PivotTable
On Error GoTo 0

If Not pt Is Nothing Then

'sets the pivot table into classic format
With pt

.RowAxisLayout xlTabularRow
End With

For Each pf In pt.PivotFields
If pf.Orientation = xlRowField Then

'This option sets all subtotal options (Sum, Count, Avg etc) to false
'pf.Subtotals = Array(False, False, False, False, False, False, False, False, False, False, False, False)
pf.Subtotals(1) = True
pf.Subtotals(1) = False
pf.RepeatLabels = True
End If
Next pf
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,132,685
Messages
5,654,748
Members
418,149
Latest member
amamiche67

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
Top