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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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