Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Changing trendline color and weight


I need to use VBA code to change the color and the thickness of
trendlines in a chart I generated using VBA. For the life of me I
cannot generate working code to change these trendline properties.
Surely this can be done. If someone could help me out it would be
greatly appreciated.


--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=526311

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Changing trendline color and weight

Sub test()
Dim cht As Chart
Dim sr As Series
Dim tr As Trendline

Set cht = ActiveSheet.ChartObjects(1).Chart
Set sr = cht.SeriesCollection(1)
Set tr = sr.Trendlines(1)

tr.Border.ColorIndex = 3
tr.Border.LineStyle = xlDash 'xlContinuous
tr.Border.Weight = xlThick ' xlThin

End Sub

Regards,
Peter T

"biosci" wrote in
message ...

I need to use VBA code to change the color and the thickness of
trendlines in a chart I generated using VBA. For the life of me I
cannot generate working code to change these trendline properties.
Surely this can be done. If someone could help me out it would be
greatly appreciated.


--
biosci
------------------------------------------------------------------------
biosci's Profile:

http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=526311



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Changing trendline color and weight

Formating the trendline's border is what you're looking for I believe:

Sub Test()
Dim cht As Chart
Set cht = ActiveSheet.ChartObjects(1).Chart
With cht.SeriesCollection(1).Trendlines(1).Border
.ColorIndex = 3
.Weight = xlThin
.LineStyle = xlContinuous
End With
End Sub

Regards,
Greg

"biosci" wrote:


I need to use VBA code to change the color and the thickness of
trendlines in a chart I generated using VBA. For the life of me I
cannot generate working code to change these trendline properties.
Surely this can be done. If someone could help me out it would be
greatly appreciated.


--
biosci
------------------------------------------------------------------------
biosci's Profile: http://www.excelforum.com/member.php...o&userid=32827
View this thread: http://www.excelforum.com/showthread...hreadid=526311


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
different color on scatter plot separated by a trendline Laoballer Charts and Charting in Excel 1 January 31st 09 08:03 AM
Changing line weight in plot Rueben6 Charts and Charting in Excel 1 January 26th 09 02:38 PM
Changing number precision of a trendline equation Harsh_Shah Excel Programming 4 August 22nd 05 02:17 AM
how to create a multiple-color trendline in excel? zibel_boy Charts and Charting in Excel 1 August 3rd 05 12:42 PM
changing font color and weight in comment boxes Beaux Excel Programming 2 May 26th 04 09:46 PM


All times are GMT +1. The time now is 08:51 AM.

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"