+ Reply to Thread
Results 1 to 2 of 2

Format a Trendline DataLabel

  1. #1
    Registered User
    Join Date
    03-02-2013
    Location
    usa
    MS-Off Ver
    Excel 2007
    Posts
    11

    Format a Trendline DataLabel

    Greetings,

    I am adding a trendline to a scatter plot and turning on the equation. I have been able to figure out how to format the datalabel of the trendline up until I want to turn on the line around the datalabel. I have tried line, lineformat, and borders. Below is the VBA code.

    Cheers,

    Mark.


    ' VBA code
    ActiveChart.SeriesCollection(1).Trendlines.Add
    ActiveChart.SeriesCollection(1).Trendlines(1).Select
    With Selection
    .Type = xlLogarithmic
    .DisplayEquation = True
    .DisplayRSquared = True
    End With

    ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel.Select
    With Selection
    .Left = 400
    .Top = 200
    .NumberFormat = "0.000E+00"
    End With

    With Selection.Font
    .Name = "Arial"
    .FontStyle = "Regular"
    .Size = 12
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ColorIndex = xlAutomatic
    End With

    With Selection.Fill
    .Solid
    .ForeColor.SchemeColor = 2
    End With

    With Selection.Lines
    .Weight = 0.75
    .DashStyle = msoLineSolid
    .Style = msoLineSingle
    .Visible = msoTrue
    .ForeColor.SchemeColor = 0
    End With

    ActiveChart.ChartArea.Select

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Format a Trendline DataLabel

    Hi,

    Try this code in the correct place in your macro:
    Please Login or Register  to view this content.
    I hope this helps

    Oh and here's a few quick tips for you:
    1) Always indent your code, as it make it easier to read
    2) Always use code tags around your code, as this is one of the Forum rules
    3) If you aren't sure of how to do something in VBA, try using the macro recorder while you manually perform the same task, and see if you can interpret the code and make sense of what it's doing.

    Have a great day

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel 2010 Trendline With Data labels or number on forward forecast trendline
    By camelight in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 10-15-2015, 08:35 AM
  2. Conditional format colour of trendline?
    By Si902 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-07-2013, 03:14 PM
  3. conditional format for trendline
    By Ralem in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-09-2010, 09:13 AM
  4. VBA Creating DataLabel Deleting DataLabel Testing if DataLabel is attached to Point
    By batmanfan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2010, 12:58 AM
  5. Dialog Format Trendline
    By Zurn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2005, 09:39 AM

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