Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Maintain Pivot Chart Formatting after Refresh?

$
0
0

Excel 2010 ... First, I know nothing regarding VBA Code ... I record Macros only, sometimes followed by some creative cut/paste ... & I believe Macros are stored in Charts, WorkSheets, Modules, & WorkBooks??? ... Ok, now that my Code short-comings are out of the way ...

Excel 2003 ... I had a recorded Macro which set the formatting of various Datapoints, Fonts etc for a Pivot Chart ... This Macro was located in "Charts" & worked great ... Then within 6 months I was refreshed to Excel 2007 ... then up to Excel 2010 ... Now the Excel 2003 Code no longer works ... So I recorded a new Macro (below), but when I went to put it into "Charts" I found that "Charts" did not exist ... What I have now is "Sheet3 (Chart)", so I put the Macro here ... However, it does not always work (also, I am running the Pivot Chart with Slicers so do not know if this has any impact?) 

I need to know what revisions to make (if any) to the following recorded Macro ...

Where to store the Macro since I do not see a "ChartSheet" ...

How to fire the Macro off (Worksheet_Calculate or other) ...

 

Private Sub Worksheet_Calculate()
   
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).Points(1).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 102, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(13).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(102, 102, 153)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(25).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(102, 102, 153)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).Points(38).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 0, 0)
        .Transparency = 0
        .Solid
    End With
    ActiveChart.SeriesCollection(1).DataLabels.Select
    With Selection.Format.TextFrame2.TextRange.Font
        .NameComplexScript = "Arial"
        .NameFarEast = "Arial"
        .Name = "Arial"
    End With
    Selection.Format.TextFrame2.TextRange.Font.Size = 6
    ActiveChart.PlotArea.Select
   
'    Range("A1").Select
   
    ActiveChart.Deselect
    ActiveChart.HasLegend = False
   
End Sub

Many "Thanks" to you that are intimate with Excel & who provide the many valuable solutions found in these Forums ... Kha


Kha422


Viewing all articles
Browse latest Browse all 11829

Trending Articles