+ Reply to Thread
Results 1 to 3 of 3

How to set XY Line Chart Title text?

Hybrid View

ThomasHaller How to set XY Line Chart... 01-19-2012, 03:54 PM
tom1977 Re: How to set XY Line Chart... 01-19-2012, 04:56 PM
ThomasHaller Re: How to set XY Line Chart... 01-20-2012, 08:22 AM
  1. #1
    Registered User
    Join Date
    12-05-2011
    Location
    Cincinnati, OH
    MS-Off Ver
    Excel 2007
    Posts
    40

    Question How to set XY Line Chart Title text?

    Hello folks,

    I am using an X-Y Line Chart and I cannot seem to find the syntax to set the chart title!?!

    Here is an example of my attempts, that always gives the error

    "Run-time error '438': Object does support this property or method"

    Worksheets("Cond Graphs").ChartObjects("Chart 1").ChartTitle.Text = "Conductivity"
    Can anyone help with what I am doing wrong? I've tried removing the ".Text", I have tried various ways of identifying the chart, but I always get that same error message.

    - Thomas
    Last edited by ThomasHaller; 01-20-2012 at 08:22 AM. Reason: title edit

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: How to set XY Line Chart Title text?

    try maybe this
    Sub bb()
    With Sheets("Cond Graphs").ChartObjects("Chart 1")
    .Chart.HasTitle = True
    .Chart.ChartTitle.Text = "Conductivity"
    End With
    End Sub
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Registered User
    Join Date
    12-05-2011
    Location
    Cincinnati, OH
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: How to set XY Line Chart Title text?

    Thanks tom,

    It looks like your code would work, the problem with mine was I was leaving out the object descriptor ".Chart", after the ChartObjects("Chart 1"). and before the ChartTitle. Here is the line from my code that works:

    Worksheets("Cond Graphs").ChartObjects("Chart 1").Chart.ChartTitle.Text = "Conductivity"
    Then I got fancy, as I wanted the Chart Title to come from the imported data:

    ' Set Chart Title from appropriate cell on AIO-Cond data import sheet
    
    Dim ChartTitle As String
    
    ChartTitle = Worksheets("AIO-Cond").Range("C2") & Worksheets("AIO-Cond").Range("C3")
    
    Worksheets("Cond Graphs").ChartObjects("Chart 1").Chart.ChartTitle.Text = ChartTitle
    Problem Solved!

    - Thomas
    Last edited by ThomasHaller; 01-20-2012 at 08:46 AM.

+ 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