VBA code that selects Chart Points by Data Label

Marty Nix

New Member
Joined
Sep 10, 2002
Messages
4
In a macro I'm writing I'm trying to locate a data point with a particular label on a Stacked Column chart and change its interior color. Since the point can potentially be in any position, I can't use a static Index. Any advice is appreciated.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi Marty,

Here is an example of some code that does this:

With Worksheets(1).ChartObjects(1).Chart
For i = 1 To .SeriesCollection(1).Points.Count
With .SeriesCollection(1).Points(i)
If .HasDataLabel Then
If .DataLabel.Text = "Hello" Then
.DataLabel.Interior.ColorIndex = 3
End If
End If
End With
Next i
End With

This code looks for a label named "Hello" (case-sensitive) and changes its interior color to red.
 
Upvote 0

Forum statistics

Threads
1,214,808
Messages
6,121,684
Members
449,048
Latest member
81jamesacct

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