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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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
 
Upvote 0
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!
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,176
Members
448,948
Latest member
spamiki

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