LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to format trendline as same color as series line in XL2007

I am using Excel 2007. I want to change the trendline color (and type/width)
to match the color of it's parent data series line color. i have this vb
code which works well provided i manually set the color of data line and
trendline first. if the color is set by Automatic color assignment (which is
default) then the code does not work and color doesn't change (but linetype
and width changes). I am not sure
if this is a bug or something i am not doing properly...

Sub change_trendlines()
Dim mysrcolor, myset As ColorFormat
Dim ch1 As ChartObject
Dim series1 As Series
Dim trend1 As Trendline
Dim myline As LineFormat


For Each ch1 In ActiveSheet.ChartObjects
ch1.Activate
For Each series1 In ActiveChart.SeriesCollection
Set mysrcolor = series1.Format.Line.ForeColor
For Each trend1 In series1.Trendlines
Set myline = trend1.Format.Line
myline.DashStyle = msoLineDash
myline.Weight = 2
myline.ForeColor.RGB = mysrcolor.RGB
Next trend1
Next series1
ch1.Activate
Next ch1

End Sub

any help on this is highly appreciated

 
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
change series or line color in excel 2007 vba Nick Charts and Charting in Excel 4 April 6th 10 02:31 PM
Line Series Color on Graph Nate Excel Discussion (Misc queries) 2 January 13th 10 07:35 PM
Polynomial trendline XL2007 Bernard Liengme Excel Discussion (Misc queries) 1 October 27th 08 05:31 PM
Polynomial trendline XL2007 Bernard Liengme Charts and Charting in Excel 1 October 27th 08 05:31 PM
Trendline color format bug/issue? satishbhave Excel Programming 9 August 12th 08 03:40 AM


All times are GMT +1. The time now is 09:50 PM.

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

About Us

"It's about Microsoft Excel"