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
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