title: VBA incorrectly entering range as series name
body: <p>I'm trying to create a dynamic graph in VBA in Excel. Unfortunately, when I generate the graph the values that are meant for the y axis are ending up as the series name. <a href="http://i.stack.imgur.com/ubtCU.png" rel="nofollow">Here's the graph</a>. I'm an extremely new VBA user, so I'm sure I am just overlooking a very basic error. Here is my code.</p>
  
  <pre><code>Sheets("Sheet1").Activate
  
  Dim lRow As Long
  Dim lCol As Long
  
  'Find the last non-blank cell in column G and H
  Range("G3:H500").Select
  Do Until ActiveCell.Value = ""
  ActiveCell.Offset(1, 0).Select
  Loop
  lastrow = ActiveCell.Row - 1
  
  'Find the last non-blank cell in row 1
  lCol = Cells(1, Columns.Count).End(xlToLeft).Column
  
  MsgBox "Last Row: " &amp; lastrow &amp; vbNewLine &amp; _
          "" &amp; Columns(lCol).Address(False, False)
  
  Set rng = Range("G3:H300" &amp; lastrow)
  Set xrang = Range("F3:F300" &amp; lastrow)
  
  rng.Select
  
  ActiveSheet.Shapes.AddChart.Select
  ActiveChart.ApplyChartTemplate ( _
      "c:\users\name\appdata\Roaming\Microsoft\Templates\Charts\brand_line_chart.crtx" _
      )
  ActiveChart.SetSourceData Source:=Range("G3:H300" &amp; lastrow)
  ActiveChart.Axes(xlCategory).Select
  ActiveChart.SeriesCollection(1).XValues = Range("F3:F300" &amp; lastrow)
  </code></pre>
  
  <p>Any help would be greatly appreciated, thank you!</p>