Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Format Data Series in a Pivot Chart

Hello,

I have 2 pivot charts, which both have the same data series, but depending
on the selections made not all the data series will be used.
I have recorded the code below from the macro recorderto format each series
in a particular colour.

But if say "Late" is not in the data selected, it gives me a run time error.

How can I modify the code so that it will look for each data series and if
not found go to the next data series.

Sub FormatSeries ()

Application.ScreenUpdating = False

ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 39
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Fill.OneColorGradient Style:=msoGradientHorizontal,
Variant:=1, _
Degree:=0.231372549019608
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 15
End With




ActiveChart.SeriesCollection("Early").Select

With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 27
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection("Late").Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection("OnTime").Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With

Application.ScreenUpdating = True



End Sub

Any help/assistance would be greatly appreciated.

Winnie


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default Format Data Series in a Pivot Chart

I have realised this is more trouble than it is worth, so have decided to
create the graphs as non pivot.That way I will keep the formatting.

Thanks



"winnie123" wrote:

Hello,

I have 2 pivot charts, which both have the same data series, but depending
on the selections made not all the data series will be used.
I have recorded the code below from the macro recorderto format each series
in a particular colour.

But if say "Late" is not in the data selected, it gives me a run time error.

How can I modify the code so that it will look for each data series and if
not found go to the next data series.

Sub FormatSeries ()

Application.ScreenUpdating = False

ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 39
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Fill.OneColorGradient Style:=msoGradientHorizontal,
Variant:=1, _
Degree:=0.231372549019608
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 15
End With




ActiveChart.SeriesCollection("Early").Select

With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 27
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection("Late").Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection("OnTime").Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With

Application.ScreenUpdating = True



End Sub

Any help/assistance would be greatly appreciated.

Winnie


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 461
Default Format Data Series in a Pivot Chart

You could use this:


Dim srs As Series

For Each srs In ActiveChart.SeriesCollection
Select Case srs.Name
Case "Early"
' formatting for Early series
Case "Late"
' formatting for Late series
Case "On Time"
' formatting for On Time series
Case Else
' formatting for any other series
' or just omit
End Select


You can also improve the efficiency of your code if you don't select
objects. Change this:

ActiveChart.SeriesCollection("Late").Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With

to this:

With ActiveChart.SeriesCollection("Late")
With .Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
.Shadow = False
.InvertIfNegative = False
With .Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
End With

And since most of these settings are defaults recorded by the Macro
Recorder, you can shorten this whole thing to one line:

ActiveChart.SeriesCollection("Late").Interior.Colo rIndex = 3


- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/



winnie123 wrote:
Hello,

I have 2 pivot charts, which both have the same data series, but depending
on the selections made not all the data series will be used.
I have recorded the code below from the macro recorderto format each series
in a particular colour.

But if say "Late" is not in the data selected, it gives me a run time error.

How can I modify the code so that it will look for each data series and if
not found go to the next data series.

Sub FormatSeries ()

Application.ScreenUpdating = False

ActiveChart.PlotArea.Select
With Selection.Border
.ColorIndex = 39
.Weight = xlThin
.LineStyle = xlContinuous
End With
Selection.Fill.OneColorGradient Style:=msoGradientHorizontal,
Variant:=1, _
Degree:=0.231372549019608
With Selection
.Fill.Visible = True
.Fill.ForeColor.SchemeColor = 15
End With




ActiveChart.SeriesCollection("Early").Select

With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 27
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection("Late").Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
ActiveChart.SeriesCollection("OnTime").Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With

Application.ScreenUpdating = True



End Sub

Any help/assistance would be greatly appreciated.

Winnie


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format data series (Chart) KRK New Users to Excel 2 December 26th 09 12:23 PM
Format Data Series in a Chart Jennifer Excel Worksheet Functions 4 May 22nd 07 08:22 PM
Pivot Chart - X,Y & Data Series Options Graham Haslehurst Charts and Charting in Excel 4 November 24th 05 02:51 PM
Format Series in Pivot Chart tobriant[_2_] Excel Programming 1 October 18th 05 01:13 PM
Format Data Series in Pivot Chart tobriant Excel Programming 1 October 18th 05 01:12 PM


All times are GMT +1. The time now is 05:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"