title: Excel VBA Chart With Multiple Series But Same X Value
body: <p>I'm trying to put together a VB script in Excel which creates a 'Stacked Bar Chart'.</p>
  
  <p>From examples found in this <a href="http://peltiertech.com/Excel/ChartsHowTo/VBAExcelXYCharts.html" rel="nofollow">site</a>, I did the following code:</p>
  
  <pre><code>Sub AddNewSeries()
      ActiveSheet.Shapes.AddChart2(297, xlBarStacked).Select
      With ActiveChart.SeriesCollection.NewSeries
          .Name = ActiveSheet.Range("$E$3")
          .Values = ActiveSheet.Range("IFPStart")
          .XValues = ActiveSheet.Range("IFPPN")
          .Name = ActiveSheet.Range("$G$4")
          .Values = ActiveSheet.Range("IFPBC")
          .XValues = ActiveSheet.Range("IFPPN")
           .Name = ActiveSheet.Range("$H$4")
          .Values = ActiveSheet.Range("IFPBT")
          .XValues = ActiveSheet.Range("IFPPN")
           .Name = ActiveSheet.Range("$I$4")
          .Values = ActiveSheet.Range("IFPEC")
          .XValues = ActiveSheet.Range("IFPPN")
           .Name = ActiveSheet.Range("$J$4")
          .Values = ActiveSheet.Range("IFPFin")
          .XValues = ActiveSheet.Range("IFPPN")
          .Name = ActiveSheet.Range("$K$4")
          .Values = ActiveSheet.Range("IFPIMS")
          .XValues = ActiveSheet.Range("IFPPN")
          .Name = ActiveSheet.Range("$L$4")
          .Values = ActiveSheet.Range("IFPInf")
          .XValues = ActiveSheet.Range("IFPPN")
          .Name = ActiveSheet.Range("$M$4")
          .Values = ActiveSheet.Range("IFPPT")
          .XValues = ActiveSheet.Range("IFPPN")
          .Name = ActiveSheet.Range("$N$4")
          .Values = ActiveSheet.Range("IFPSols")
          .XValues = ActiveSheet.Range("IFPPN")
      End With
  End Sub
  </code></pre>
  
  <p>You'll see that rather than using cell references, I use named ranges because the data will be dynamic.</p>
  
  <p>The code does run without any errors displayed, but the last series used i.e. </p>
  
  <pre><code>.Name = ActiveSheet.Range("$N$4")
  </code></pre>
  
  <p>overwrites the previously plotted data.</p>
  
  <p>What am I doing wrong?</p>