Bold series labels in a chart?

TrippyTom

Well-known Member
Joined
Nov 16, 2004
Messages
587
What's the proper code to bold ALL series labels in a chart? I want to set them to Arial, 10 pt, Bold.
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

vconfused

Well-known Member
Joined
Jun 11, 2004
Messages
547
Like this?
Code:
Sub Macro1()
Dim i As Integer
    
    For i = 1 To ActiveChart.SeriesCollection.Count
        With ActiveChart.SeriesCollection(i).DataLabels.Font
            .Bold = True
            .Name = "Arial"
            .Size = 10
        End With
    Next

End Sub
 

TrippyTom

Well-known Member
Joined
Nov 16, 2004
Messages
587
Perfect, thanks vconfused. :)

I think this is exactly what I needed. I didn't know it would have to go in a loop. I was on the wrong track thinking there was a single object I could adjust instead of using a variable. Thanks a ton, this helps a lot.
 

TrippyTom

Well-known Member
Joined
Nov 16, 2004
Messages
587

ADVERTISEMENT

hmm... this works at home (Excel 2003), but at work, we use Excel 2000 and it's not working. Does anyone know the proper syntax for it to work in that version?
 

vconfused

Well-known Member
Joined
Jun 11, 2004
Messages
547
Should work, but with the code, it uses ActiveChart, so you have to click on the chart to select it before running the code, otherwise you will get an error.

If you do not want to click on the chart first, you could do something like:

Code:
Sub Macro1()
Dim i As Integer
    
    ActiveSheet.ChartObjects("Chart 1").Activate
    For i = 1 To ActiveChart.SeriesCollection.Count
        With ActiveChart.SeriesCollection(i).DataLabels.Font
            .Bold = True
            .Name = "Arial"
            .Size = 10
        End With
    Next

End Sub
 

TrippyTom

Well-known Member
Joined
Nov 16, 2004
Messages
587

ADVERTISEMENT

No, it doesn't. :cry:

I copied it directly into a new worksheet and had a generic chart selected to test it, ran the macro and it came up with an error message stating:

Code:
Run-time error '1004':
Unable to get the Font property of the Datalabels class
[end] [debug] [help]

NEVERMIND! It's because the chart had no labels. Is there a way I can force it to have labels first? :)
 

TrippyTom

Well-known Member
Joined
Nov 16, 2004
Messages
587
Nevermind, I figured it out.
Code:
Sub Macro1()
Dim i As Integer
    
    For i = 1 To ActiveChart.SeriesCollection.Count
        With ActiveChart.SeriesCollection(i)
            .HasDataLabels = True
            .DataLabels.Font.Bold = True
            .DataLabels.Font.Size = 10
            .DataLabels.Font.Name = "Arial"
        End With
    Next

End Sub

Thanks so much for your help! These discrepencies between 2000 and 2003 are gonna drive me insane! :devilish:
 

ESICorp

New Member
Joined
Jun 11, 2002
Messages
36
Bolding Select Labels

Hi all-

Saw this post which is close to my problem.

How can I get only some labels bold (similar to conditional formatting for cells)?

My goal is to present 3 data series with labels using xy scatter and bold for values above a threshold for a 3rd.

Thanks,
Brian
 

Watch MrExcel Video

Forum statistics

Threads
1,122,694
Messages
5,597,571
Members
414,156
Latest member
WDMix

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
Top