I have (what I believe to be) an advanced VBA issue. I have 8 pie charts on a sheet, and would like to color each of the slices according to their category name. I've been able to use Select Case to color the pieces, but it is rather laborious to define each point, as any 1 chart may have numerous data points. Ideally, I'd like to be able to lookup the point category name in a named range, and have it spit out a RGB value. I've taken this as far as I think I can. Here's what I have so far. Thank you in advance for any assistance. It is much appreciated.
[/QUOTE]Sub FormatCharts() With ActiveWorkbook.Worksheets("Individual Portfolio Overview")ChartColor .ChartObjects(2).chartChartColor .ChartObjects(3).chartChartColor .ChartObjects(4).chartChartColor .ChartObjects(5).chartChartColor .ChartObjects(6).chartChartColor .ChartObjects(7).chartChartColor .ChartObjects(8).chartChartColor .ChartObjects(9).chartSub ChartColor(Cht As Chart) Dim chseries As Series NumPoints = Cht.SeriesCollection(1).Points.Count For X = 1 To NumPoints If Cht.SeriesCollection(1).Points(X).HasDataLabel = True Then SavePtLabel = Cht.SeriesCollection(1).Points(X).DataLabel.Text Else SavePtLabel = "" End If Cht.ApplyDataLabels Type:=xlDataLabelsShowLabelAndPercent, AutoText:=True thispt = Cht.SeriesCollection(1).Points(X).DataLabel.Text Select Case thispt Case thispt Cht.SeriesCollection(1).Points(X).Interior.Color = RGB(vlookup(thispt, Reference: "RGB",2,false),vlookup(thispt, Reference: "RGB",3,false),vlookup(thispt, Reference: "RGB",4,false)) Case Else End Select Next
Last edited by Jbryce22; 12-21-2011 at 04:23 PM.
See if this help. If you need more help post examlpe file.
http://peltiertech.com/WordPress/vba...ategory-label/
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks