Custom Data Labels for Scatter Plot

white84

New Member
Joined
May 11, 2018
Messages
40
Office Version
  1. 365
Platform
  1. Windows
I have data in a table such as this example, tracking recentcompetitions. Most data is in pivot table, but then cells are linked to astandard table. I have conditional formatting to highlight the status of the competition based on Active/Won/Lost (No color/Green/Red).

This is then linked to an XY Scatter plot based on this criteria, with data labelson the scatter plot only showing the customer name, and a box around the namecolored to correspond to the Green/Red Won/Lost status.

When I update monthly and refresh the pivot table, the conditionalformatting works fine in the table but formatting of the data labels on thechart get jumbled (Some active turn a color, some Won/Lost will switch color).
Is there a way to link or set formatting based on a sortof lookup, so I can refresh the data and don’t have to reset the data labelseach time. (Numerous customers, numerous criteria).

Thanks in advance!

Customer Name

<tbody>
[TD="width: 156, bgcolor: transparent"] Criteria1
[/TD]
[TD="width: 156, bgcolor: transparent"] Criteria 2
[/TD]
[TD="width: 156, bgcolor: transparent"] Status
[/TD]

[TD="width: 156, bgcolor: transparent"]Customer1

[/TD]
[TD="width: 156, bgcolor: transparent"] 5
[/TD]
[TD="width: 156, bgcolor: transparent"] $3
[/TD]
[TD="width: 156, bgcolor: transparent"] Won
[/TD]

[TD="width: 156, bgcolor: transparent"] Customer2
[/TD]
[TD="width: 156, bgcolor: transparent"] 2
[/TD]
[TD="width: 156, bgcolor: transparent"] $9
[/TD]
[TD="width: 156, bgcolor: transparent"] Won
[/TD]

[TD="width: 156, bgcolor: transparent"] Customer3
[/TD]
[TD="width: 156, bgcolor: transparent"] 12
[/TD]
[TD="width: 156, bgcolor: transparent"] $25
[/TD]
[TD="width: 156, bgcolor: transparent"] Active
[/TD]

[TD="width: 156, bgcolor: transparent"] Customer4
[/TD]
[TD="width: 156, bgcolor: transparent"] 7
[/TD]
[TD="width: 156, bgcolor: transparent"] $11
[/TD]
[TD="width: 156, bgcolor: transparent"] Lost
[/TD]

[TD="width: 156, bgcolor: transparent"] Customer5
[/TD]
[TD="width: 156, bgcolor: transparent"] 9
[/TD]
[TD="width: 156, bgcolor: transparent"] $14
[/TD]
[TD="width: 156, bgcolor: transparent"] Won
[/TD]

</tbody>
 
IT WORKED!

Thank you VERY much!

For anyone else interested here is my final code. I decided to remove the [White] formatting from "Active" so there was not as much overlap. I also changed the font color to black.

Code:
Sub FormatLabels()
Dim s As Series, y, dl As DataLabel, i%, r As Range
Set r = [k5]
Set s = ActiveSheet.ChartObjects("chartA320").Chart.SeriesCollection(1)
y = s.Values
For i = LBound(y) To UBound(y)
    Set dl = s.Points(i).DataLabel
    Select Case r
        Case Is = "Won"
            dl.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
            dl.Format.Fill.ForeColor.RGB = RGB(5, 250, 5)
        Case Is = "Lost"
            dl.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = RGB(0, 0, 0)
            dl.Format.Fill.ForeColor.RGB = RGB(250, 5, 5)
    End Select
    Set r = r.Offset(1)
Next
End Sub
 
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
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