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.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
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
 
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0
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? :)
 
Upvote 0
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:
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,968
Messages
6,122,509
Members
449,089
Latest member
RandomExceller01

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