Keepintg pivot table formatting during refresh

ashleywanless

Board Regular
Joined
Aug 4, 2009
Messages
158
Hi,

Have some pivot tables, linked to charts which refresh automatically upon opening.

Only problem is the table's loose the color formats from the bars, and sometimes the scales are not correctly adjusted. Does anybody know the code for an event macro which will cause the graphs to be re-formatted how i had them before everytime a pivot refresh action happens? It is possible the pivots are updated more often that on just opening which is why i need a macro based on a pivot refresh event.

Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
so if i use a calculate event this should work? if i insert this as a private macro into the workbook this would work for all pivot tables?

Thanks
 
Upvote 0
The procedure stub would be:

Code:
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
 
End Sub

which you can get by clicking the appropriate dropdowns at the top of the code window in the VBE.
 
Upvote 0
Hi,

thanks for that. still learning to use vbe.

So the dropdowns at the top contain all event types?

If i then just paste in some code of me recording the formatting of the graph would that work?

Thanks
 
Upvote 0
So the dropdowns at the top contain all event types?

Yes.

If i then just paste in some code of me recording the formatting of the graph would that work?

Yes, though code of the macro recorder very often needs to get cleaned up, and made generic (e.g. add constants to avoid having the same thing appearing too many times in the code like sheet names, ranges, ...)
 
Upvote 0
Thanks for your help with this. Sorry for the lare reply i have been on holiday. Final code looks like this, although the last line to do with column B is just an autofit.

Private Sub Worksheet_Calculate()
ActiveSheet.ChartObjects("Chart 12").Activate
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 11
.Pattern = xlSolid
End With
ActiveWindow.Visible = False
Windows("Legal Incidents Dashboard.xls").Activate
Columns("B:B").EntireColumn.AutoFit
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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