hi
I have a stacked area chart located on its own individual worksheet. I would like to use VBA to apply colours to individual series based on the name of that series. I have applied the following code which I found on the following help forum, changing it slightly to fit my needs: http://www.ozgrid.com/forum/showthread.php?t=91381
heets("Human Resource Requirements").Select
If ActiveChart.ChartType = xlStackedArea Then
NumPoints = ActiveChart.SeriesCollection(1).Points.Count
For x = 1 To NumPoints
' Save the label currently attached to the current slice
If ActiveChart.SeriesCollection(1).Points(x).HasDataLabel = True Then
savePtLabel = ActiveChart.SeriesCollection(1).Points(x).DataLabel.Text
Else
savePtLabel = ""
End If
' Assign a new data label of just the point name
ActiveChart.SeriesCollection(1).Points(x).ApplyDataLabels Type:= _
xlDataLabelsShowLabel, AutoText:=True
ThisPtx = ActiveChart.SeriesCollection(1).Points(x).DataLabel.Text
Select Case ThisPtx
Case "Water"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 41
Case "Roads"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 19
Case "Rail"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 22
Case "Ports"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 25
Case "Industrial"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 30
Case "Resource Engineering"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 35
Case "Airports"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 34
Case "Energy"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 38
Case "Oil and Gas"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 38
Case "Water Treatment"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 41
Case "Water Transmission"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 41
Case "Wastewater Treatment"
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 41
Case Else
' Aroo! The label of the current slice doesn't match any expected labels
ActiveChart.SeriesCollection(1).Points(x).Interior.ColorIndex = 1
End Select
ActiveChart.SeriesCollection(1).Points(x).ApplyDataLabels Type:=xlDataLabelsShowValue, AutoText:=True
Next x
End If
Can some one please identify the problem with this code as it doesnt cause any change in the chart
cheers
DUT
Bookmarks