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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
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.
 

Forum statistics

Threads
1,144,274
Messages
5,723,442
Members
422,497
Latest member
dougy99

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
Top