+ Reply to Thread
Results 1 to 3 of 3

Need VBA to remove trendlines

Hybrid View

RandyV Need VBA to remove trendlines 05-14-2011, 06:23 PM
NearlySink Re: Need VBA to remove... 01-17-2012, 06:30 PM
Andy Pope Re: Need VBA to remove... 01-18-2012, 06:04 AM
  1. #1
    Registered User
    Join Date
    05-14-2011
    Location
    Colorado
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need VBA to remove trendlines

    One of my protected worksheets has an embedded line chart, as well as button-activated macros that allow users (most in Excel ‘07 or ‘10, some in ‘03) to add or remove the trendline for each of the several data series. I can add a trendline, but would appreciate your suggestions as to how to subsequently remove it.

    Successful Add:
    With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(7).Trendlines.Add
    Unsuccessful Remove attempt:
    With ActiveSheet.ChartObjects(1).Chart.SeriesCollection(7).Trendlines.Remove
    Results in: Run-Time error '438': Object doesn’t support this property or method.

    I’m a novice VBA user working in Excel 2010. Thanks for considering this!
    Last edited by RandyV; 05-16-2011 at 02:10 PM. Reason: found solution elsewhere

  2. #2
    Registered User
    Join Date
    01-17-2012
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Need VBA to remove trendlines

    Hey Randy, you can use ActiveChart.SetElement (msoElementTrendlineNone) to remove a trend line from a graph.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Need VBA to remove trendlines

    You need to provide an index,

    activechart.SeriesCollection(1).trendlines(1).delete
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1