Help! Only top series is displaying on line chart

reneuend

Board Regular
Joined
May 20, 2009
Messages
155
I'm building a chart dynamically with 6 series on a stacked line chart (xlLineMarkersStacked).
For some reason, only the top series is displaying on the plot area. All series have data behind them and are represented on the legend.

If I right click on the plot area, and select "Select Series". Then use the "up arrow" move a lower series to the top of the order, it then displays and the previous series that was on top disappears along with the rest of the series that are not at the top.

Any ideas why? :(


Code:
Function BuildProcessChart(ByVal bShowSurfaceWind) As Boolean
 
    Dim nLastProcessRow As Integer, nSeriesIdx As Integer, idx As Integer
    Dim dMaxVal As Double
    Dim sRange As String
    Dim chObj As ChartObject
 
    ActiveWorkbook.Worksheets(PROCESSWIN_TAB).Activate
    'Remove existing charts on this worksheet
    On Error Resume Next
    For Each chObj In ActiveSheet.ChartObjects
        chObj.Delete
    Next chObj
 
 
    '!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GET MAXIMUM VALUE from process data worksheet
    nLastProcessRow = xlLastRow(PROCESSDATA_TAB)
 
    If nLastProcessRow < 2 Then
        BuildProcessChart = False
        MsgBox "No Data found to process", vbCritical, "No Data"
        Exit Function
    Else
        BuildProcessChart = True
    End If
 
    sRange = "E2:I" & nLastProcessRow
    Set rRange = ActiveWorkbook.Worksheets(PROCESSDATA_TAB).Range(sRange)
    With ActiveWorkbook
        dMaxVal = Application.Max(rRange)
    End With
    nMaxScaleVal = Application.RoundUp(dMaxVal, 0) + 500
 
 
    'Go to the Process Chart worksheet
    ActiveWorkbook.Worksheets(PROCESSWIN_TAB).Activate
 
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlLineMarkersStacked
 
    'get the chart name for use in other routines
    pos1 = InStr(1, ActiveChart.Name, "Chart")
    lenChartName = Len(ActiveChart.Name) - pos1 + 1
    gPWChartName = Right(ActiveChart.Name, lenChartName)
 
    ActiveChart.Axes(xlValue).Select
    With ActiveChart.Axes(xlValue)
        .MinimumScale = 0
        .MaximumScale = Round(dMaxVal) + 100
        .MinorUnitIsAuto = True
        .MajorUnit = gProcChartYMajorUnits
        .HasMajorGridlines = True
        .MajorGridlines.Border.Color = RGB(200, 200, 200)
        .Crosses = xlAutomatic
        .ReversePlotOrder = False
        .ScaleType = xlLinear
        .DisplayUnit = xlNone
    End With
 
    sSeriesStringStart = "='Process Data'!"
    sSeriesRowStart = "$2"
    sSeriesRowEnd = "$" & nLastProcessRow
 
    idx = 1
 
 
        sSeriesColumn = "$I"
        ActiveChart.SeriesCollection.NewSeries
        ActiveChart.SeriesCollection(idx).Name = "=""Break Surface Wind"""
        ActiveChart.SeriesCollection(idx).Values = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
        ActiveChart.SeriesCollection(idx).Select
        With Selection.Border
            .ColorIndex = 3
            .Weight = 2
            .LineStyle = xlContinuous
        End With
 
        With Selection
            .Smooth = True
            .MarkerStyle = xlMarkerStyleNone
        End With
 
        sSeriesColumn = "$A"
        ActiveChart.SeriesCollection(idx).XValues = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
        idx = idx + 1
 
    sSeriesColumn = "$H"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(idx).Name = "=""Test 1"""
    ActiveChart.SeriesCollection(idx).Values = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
    ActiveChart.SeriesCollection(idx).Select
    With Selection.Border
        .ColorIndex = 6
        .Weight = 2
        .LineStyle = xlContinuous
    End With
 
    With Selection
        .Smooth = True
        .MarkerStyle = xlMarkerStyleNone
    End With
 
        sSeriesColumn = "$A"
        ActiveChart.SeriesCollection(idx).XValues = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
    idx = idx + 1
    sSeriesColumn = "$G"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(idx).Name = "=""Test 2"""
    ActiveChart.SeriesCollection(idx).Values = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
    ActiveChart.SeriesCollection(idx).Select
    With Selection.Border
        .ColorIndex = 3
        .Weight = 2
        .LineStyle = xlContinuous
    End With
 
    With Selection
        .Smooth = True
        .MarkerStyle = xlMarkerStyleNone
    End With
 
        sSeriesColumn = "$A"
        ActiveChart.SeriesCollection(idx).XValues = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
 
    idx = idx + 1
    sSeriesColumn = "$F"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(idx).Name = "=""Test 3"""
    ActiveChart.SeriesCollection(idx).Values = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
    ActiveChart.SeriesCollection(idx).Select
    With Selection.Border
        .ColorIndex = 3
        .Weight = 2
        .LineStyle = xlDash
    End With
 
    With Selection
        .Smooth = True
        .MarkerStyle = xlMarkerStyleNone
    End With
 
        sSeriesColumn = "$A"
        ActiveChart.SeriesCollection(idx).XValues = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
 
    idx = idx + 1
    sSeriesColumn = "$E"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(idx).Name = "=""Test 4"""
    ActiveChart.SeriesCollection(idx).Values = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
    ActiveChart.SeriesCollection(idx).Select
    With Selection.Border
        .ColorIndex = 3
        .Weight = 2
        .LineStyle = xlDot
    End With
 
    With Selection
        .Smooth = True
        .MarkerStyle = xlMarkerStyleNone
    End With
 
        sSeriesColumn = "$A"
        ActiveChart.SeriesCollection(idx).XValues = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
 
    idx = idx + 1
    sSeriesColumn = "$J"
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.SeriesCollection(idx).Name = "=""Test 5"""
    ActiveChart.SeriesCollection(idx).Values = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
    ActiveChart.SeriesCollection(idx).Select
    With Selection.Border
        .ColorIndex = 2
        .Weight = 0
        .LineStyle = xlLineStyleNone
    End With
 
    With Selection
        .Smooth = True
        .MarkerSize = 6
        .MarkerForegroundColorIndex = 11
        .MarkerBackgroundColorIndex = 11
        .MarkerStyle = xlMarkerStyleCircle
    End With
 
        sSeriesColumn = "$A"
        ActiveChart.SeriesCollection(idx).XValues = sSeriesStringStart & sSeriesColumn & sSeriesRowStart & ":" & sSeriesColumn & sSeriesRowEnd
 
 
    With ActiveChart
 
        .Legend.Border.LineStyle = xlContinuous
 
        .Axes(xlCategory, xlPrimary).HasTitle = True
        .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = ActiveWorkbook.Sheets(GRAPH_TAB).cboXAxis.Value
        .Axes(xlValue, xlPrimary).HasTitle = True
        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = ActiveWorkbook.Sheets(GRAPH_TAB).cboYAxis.Value
 
    End With
 
    'add title to Y Axis
    With ActiveChart
        .Axes(xlValue, xlPrimary).HasTitle = True
        .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = _
        gProcessChartYAxisTitle
    End With
 
    With ActiveChart.Parent
        .Top = 170
        .Left = 100
        .Height = 335
        .Width = 714
    End With
 
 
 
End Function 'BuildProcessChart
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I found the issue. I should have been using a regular line chart instead of a stacked line. The only reason I'm building the chart in the first place is because I'm getting an error message if I only update the chart. This started happening when I ported this workbook from Excel 2003 to 2007. It seems no one really understands why the error message occurs.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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