VBA for chart function

Marty Nix

New Member
Joined
Sep 10, 2002
Messages
4
I got a very helpful response the last time I asked this question, but after I received it I realized I had asked the wrong question. At least I was able to learn from my mistake.

I'm trying to write a sequence in a macro that will find a certain TickLabel value on the Category Axis in the ActiveChart and turn the interior of the corresponding data point a different color. The data point can wind up anywhere, so using a static Index value is no good. I mistakenly asked about DataLabels before. Again, help is appreciated.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Damon Ostrander

MrExcel MVP
Joined
Feb 17, 2002
Messages
4,239
Hi Marty,

Is this what you are after?

Sub ColorPoint()
Dim S As Series
Set S = Worksheets(1).ChartObjects(1).Chart.SeriesCollection(1)
For i = 1 To S.Points.Count
If S.XValues(i) = 40 Then
S.Points(i).MarkerBackgroundColorIndex = 3
End If
Next i
End Sub

In this example the code tests for a category value of 40, but this could be a text string if the category values are text rather than numbers (e.g., S.XValues(i) = "April").

Damon
 

Marty Nix

New Member
Joined
Sep 10, 2002
Messages
4
With a little tinkering, yes, that's exactly what I needed, and a lot less sloppy than the method I was considering using. Thanks much!
 

Forum statistics

Threads
1,144,765
Messages
5,726,164
Members
422,659
Latest member
RGP268

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