Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
i've created a macro to enable/disable linear trend lines for my bar charts.
sub AddTrendlines
For x = 0 to 5 'NoOfReportPages
Objects = ActiveDocument.GetSheet(x).GetSheetObjects
For i = lBound(Objects) To uBound(Objects)
OT = Objects(i).GetObjectType
ObjectID = Objects(i).GetObjectID
if(OT = 12) then
set prop = Objects(i).GetProperties
set expr = prop.Expressions
c=expr.Count - 1
for j = 0 to c
Objects(i).AddTrend j,1,1
next
end if
next
Next
ActiveDocument.Variables("vLinearTrendline").SetContent "1", true
end sub
sub RemoveTrendlines
For x = 0 to 5 'NoOfReportPages
Objects = ActiveDocument.GetSheet(x).GetSheetObjects
For i = lBound(Objects) To uBound(Objects)
OT = Objects(i).GetObjectType
ObjectID = Objects(i).GetObjectID
if(OT = 12) then
set prop = Objects(i).GetProperties
set expr = prop.Expressions
c=expr.Count - 1
for j = 0 to c
Objects(i).RemoveTrend j,1,1
next
end if
next
Next
ActiveDocument.Variables("vLinearTrendline").SetContent "0", true
end sub
I would like to extend the macro "AddTrendlines" by the following things:
- Display equation (expression tab)
- Set a forecast value of 3 (axis tab)
- Change line style to dotted
I don't know how to realise these things via macro.
thx 4 your help.
A trend line indicates a linear relationship. The equation for a linear relationship is y = mx + b, where x is the independent variable, y is the dependent variable, m is the slope of the line, and b is the y-intercept.
Clover.com
Unfortunately your answer does not help me 😞