title: Excel 2010 Macro to Create Charts
body: <p>I am trying to create macros to build charts in Excel 2010.</p>
  
  <p>If I record a macro it gives me the following code:</p>
  
  <pre><code>ActiveSheet.Shapes.AddChart.Select
  ActiveChart.SetSourceData Source:=Range("'Sheet1'!$A$1:$I$15")
  ActiveChart.ChartType = xlColumnStacked
  </code></pre>
  
  <p>But when I rerun it, it gives me the following error:</p>
  
  <blockquote>
    <p>Run time error '1004': Application defined or object defined error.</p>
  </blockquote>
  
  <p>I have tried many different variations:</p>
  
  <pre><code>With ActiveSheet.ChartObjects.Add _
          (Left:=100, Width:=690, Top:=75, Height:=375)
      With .Chart
         .Parent.Name = "Chart MVO"
         .HasTitle = True
         .ChartTitle.Text = "MVO (628) CF and DS Delivery Performance"
      End With
   End With
  </code></pre>
  
  <p>But each gives a different run time error. What am I doing wrong?</p>