Changing the colour of text for a data label

robjowens

Board Regular
Joined
Sep 26, 2009
Messages
102
is there a macro to change the colour of the text of data label in a chart?

recorded the below but it has an issue with the 'with' statement

cheers.

HTML:
Sub Macro2()
'
' Macro2 Macro
'
'
    Range("H34").Select
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.PlotArea.Select
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.SeriesCollection(1).DataLabels.Select
 
        With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
    End With
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I assume you are using xl2007 or above? Try using the colorindex property of font:

ActiveChart.SeriesCollection(1).DataLabels.Font.ColorIndex = 3
 
Upvote 0
Your code should work. There are a few superfluous lines, but that shouldn't stop it from working as long as there are datalabels
Code:
Sub Macro1()
'
'
    ActiveSheet.ChartObjects("Chart 1").Activate
    With ActiveChart.SeriesCollection(1).DataLabels.Font
        .ColorIndex = 4
    End With
End Sub

I haven't got Excel 2007/2010, so can't test the themecolors etc. But try it with the above to see if the datalables turn to green.

The chart should have datalabels, otherwise you need to amend the macro to create these first
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

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