title: Excel VBA: Add a scatter chart to worksheet as object
body: <p><strike>I am looking to create a scatter chart that, on button press, creates a scatter chart in <code>Sheet 1</code> and uses <code>A2:A11</code> as the <code>x</code> values and <code>B2:B11</code> as the <code>y</code> values. </p>
  
  <p>Using code at the bottom allows me to create a scatter chart based off of the values in <code>A1:B3</code> (got this from <a href="http://www.programmersheaven.com/mb/vba/263264/263965/xy-scatter-curve/" rel="noreferrer">here</a>). Its close, but not exactly what I'm looking for. How can I tweak this to suit my needs?</strike></p>
  
  <p>I got it set up now so the chart is made, based on the values I want, but I can not get it to appear as an object in <code>Sheet 1</code>. How do I do this? <code>.Location xlLocationAsObject</code> doesn't seem to work.</p>
  
  <pre><code>Private Sub chartButton_Click()
      ActiveWorkbook.Charts.Add
      With ActiveWorkbook.ActiveChart
          'Data?
          .ChartType = xlXYScatter
          .SeriesCollection.NewSeries
          .SeriesCollection(1).Name = "=""Scatter Chart"""
          .SeriesCollection(1).XValues = "=Sheet1!$A$2:$A$11"
          .SeriesCollection(1).Values = "=Sheet1!$B$2:$B$11"
  
          'Location
          'DON'T KNOW WHAT TO PUT HERE
          '.location xlLocationAsObject doesn't work!
  
          'Titles
          .HasTitle = True
          .ChartTitle.Characters.Text = "Scatter Chart"
          .Axes(xlCategory, xlPrimary).HasTitle = True
          .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "X values"
          .Axes(xlValue, xlPrimary).HasTitle = True
          .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Y values"
          .Axes(xlCategory).HasMajorGridlines = True
  
          'Formatting
          .Axes(xlCategory).HasMinorGridlines = False
          .Axes(xlValue).HasMajorGridlines = True
          .Axes(xlValue).HasMinorGridlines = False
          .HasLegend = False
  
      End With
  End Sub
  </code></pre>