How to stop chart title appearing.

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
I've written some nice VBA code to create a chart with no title, but when I allow the user to remove all but the last data series (with a userform), the name of that data series pops up automatically as the chart title. I tried to stop this with [chart_reference].HasTitle = False, but the name of the last data series still pops up as the chart title when only one data series remains... :(

Is there any other way/command to override this automatic title popping up?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
What version of Excel are you using? Can we see your code?
Thanks, Andrew,

I'm using Excel 2007, updated online to 2010 (not sure if there's a difference with virgin Excel 2010?).

I'd be happy to share the code, but it's very long and scattered across two modules (including a user form), so I'd feel bad for expecting anyone read through all that. But let me describe the basic logic, then you can tell me which bit(s) of code you want to see:

1. Userform contains check boxes to define what data series are included in chart. Any changes to these call a sub to recreate the chart
2. Create chart sub essentially recreates the chart from scratch, depending on what series are checked in the user form. This sub routine includes the [chartref].HasTitle = False command at the start, before each of selected data series are added one after the other.
3. The same create chart sub then saves the chart image as a bmp file and reloads this back into the open user form.

Clearly there is something going wrong in step 2, as the title pops up when only one data series is checked in the userform, despite the hastitle = False command. But I'm not sure why it's not working... :(
 
Upvote 0
I guess the problem must be in here somewhere:

Code:
    Set DChart = ActiveSheet.Shapes.AddChart.Chart
    
    With DChart
        With .ChartArea
            .ClearContents
            .Height = DControl.ChartImage.Height
            .Width = DControl.ChartImage.Width
            .Font.Size = 10
            .Format.Fill.ForeColor.RGB = RGB(212, 208, 200)
            .Format.Line.Visible = msoFalse
        End With
        With .PlotArea
            .Format.Fill.ForeColor.RGB = RGB(255, 255, 221)
            .Format.Line.ForeColor.RGB = RGB(153, 153, 153)
            .Format.Line.Weight = 0.75
        End With
        .ChartType = xlXYScatterSmoothNoMarkers
[B]          .HasTitle = False[/B]
        .HasLegend = True
    End With

    If DControl.ShowCDF Then
    With DChart.SeriesCollection.NewSeries
        .Name = "CDF"
        .XValues = Prob
        .Values = QF
    End With
    End If
    
    If DControl.ShowPDF Then
    With DChart.SeriesCollection.NewSeries
        .Name = "PDF"
        .XValues = NPDF
        .Values = QF
    End With
    End If

    'Further code to add more data series goes here
 
Upvote 0
PS. Setting .HasTitle to True just before resetting it to False seemed to do the job. Clearly this is a bug with Excel. :mad:

Anyway, thanks again for your help Andrew.
 
Upvote 0
PS. Setting .HasTitle to True just before resetting it to False seemed to do the job. Clearly this is a bug with Excel. :mad:

Anyway, thanks again for your help Andrew. :)
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,823
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top