VBA Help - Include data label color to white

joeino

New Member
Joined
Oct 28, 2020
Messages
21
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
Hi,

Well, I found a VBA for my initial problem but right now I am having issues how to include the data labels color. Can anyone please provide me some idea on how I can add the font color in the code below. Data label color is also dependent on data series

If ser.Name = "Sent Remarks" Then
ser.Format.Fill.ForeColor.RGB = RGB(214, 8, 59)
>color font goes here


Below is the full VBA I am using.



Sub style_chart()

Dim cht As Chart
Dim ser As Series


'uses the active chart... assume it is selected
Set cht = ActiveChart


With cht
'reset legend so that it matches series
'.HasLegend = False
'.HasLegend = True

'iterate backwards to delete
For i = .SeriesCollection.Count To 1 Step -1
Set ser = .SeriesCollection(i)

'set series colors based on name
If ser.Name = "Sent Remarks" Then
ser.Format.Fill.ForeColor.RGB = RGB(214, 8, 59)
ElseIf ser.Name = "already actioned" Then
ser.Format.Fill.ForeColor.RGB = RGB(96, 38, 158)
ElseIf ser.Name = "Added annotations" Then
ser.Format.Fill.ForeColor.RGB = RGB(160, 0, 240)
End If

'delete the legend entry if after first 2
'If i > 2 Then
' .Legend.LegendEntries(i).Delete
'End If
Next i
End With

End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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