• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Show Hide Trendline with a checkbox

Partha Misra

New Member
Hi,

How do I show or hide a trendline in a chart using a checkbox or some other form control?


Please see the uploaded sample file.
 

Attachments

  • Sample Trend Chart.xlsx
    12.8 KB · Views: 5
Hi Partha Misra,

Please see this file.
 

Attachments

  • Sample Trend Chart.xlsx
    14 KB · Views: 17
Hi @Faseeh

Thanks for replying. But thats not that I am for. I want a proper trendline like the one we get when we add trendline on the data series and want to see the forecast trend for 3 months forward.

Hope you understood my point.


Regards,

Partha
 
Hi Partha..

In Case of VBA..

Code:
Private Sub CheckBox1_Click()
    If CheckBox1 Then
        Worksheets("sheet1").ChartObjects(1).Chart.SeriesCollection(1).Trendlines _
            .Add Type:=xlLinear, Name:="Linear Trend", Forward:=[c5]
        With Worksheets("sheet1").ChartObjects(1).Chart.SeriesCollection(1).Trendlines(1).Format.Line
            .Weight = 2
            .ForeColor.RGB = RGB(91, 155, 213)
            .DashStyle = 3
        End With
    Else
        Worksheets("sheet1").ChartObjects(1).Chart.SeriesCollection(1) _
        .Trendlines(1).Delete
    End If
End Sub
 

Attachments

  • Sample Trend Chart VBA.xlsm
    24.8 KB · Views: 29
Back
Top