VBS: Adding trendline to chart

I have a vbscript which is generating the excel file, data and charts
When adding a trendline to a normal line chart (Excel 2007), it adds a tick for "Set Intercept" with a default value of 0.0, how do prevent this from being active? (code attached)
Set oExcel = createobject("Excel.application")
oExcel.visible = true
oExcel.ActiveChart.Name = oTitle
oExcel.ActiveChart.ChartType = 4
oExcel.ActiveChart.SetSourceData rng, 1

oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False, False

Open in new window

Who is Participating?
jostranderConnect With a Mentor Commented:
on line 10, you have:
oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False, False

The last "False" is setting the trendline intercept to value of 0.  If you remove it
oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False
oExcel.ActiveChart.SeriesCollection(1).Trendlines.Add -4132, , 0, False,False,,False,False,"My Trendline"

Then it should be unchecked.

datacomsmtAuthor Commented:
That solved it thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.