Results 1 to 4 of 4

Stacked Area Chart Series Colour Change

Threaded View

  1. #1
    Registered User
    Join Date
    01-04-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003
    Posts
    16

    Unhappy Stacked Area Chart Series Colour Change

    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
    Last edited by downunderthunder; 01-06-2010 at 09:19 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1