title: How can I use part of a given range in vba (excel) i.e. certain rows in the range
body: <p>I have a range that references a table in excel.
  I need to create a graph and therefore set the source data using my table range.
  I want the source data to be the first row and last 2 rows from my table (the headings and 2 total rows).
  Given that the range is formed using variables, is there a way of selecting those sections of any given range (assuming the range consists of three or more rows).
  Here's my code so far:</p>
  
  <pre><code>    Sub addchart(ByVal TableRange As Range, SheetName As Worksheet, TblLabel As String, TableLabel As String)
  
      Dim ChtPosition As Range
      Dim ChtRow As Long
      Dim ChtSourceData As Range
  
      Set ChtSourceData = Union(Top row of TableRange here, Last 2 rows of TableRange here)
  
      ChtRow = SheetName.Cells(SheetName.Rows.Count, "B").End(xlUp).Row + 2
      ChtPosition = SheetName.Cells(ChtRow, 2)
  
      SheetName.Shapes.addchart.Select
      With ActiveChart
          .SetSourceData Source:=SheetName.Range(ChtSourceData)
          .ApplyChartTemplate ("\\graphtemplatefilepath")
          .Parent.Name = "Cht" &amp; TblLabel
      End With
  
      With SheetName.ChartObjects("Cht" &amp; TblLabel)
          .Width = (16 * 29)
          .Height = (7 * 29)
          .Left = ChtPosition.Left
          .Top = ChtPosition.Top
          .Chart.ChartTitle.Characters.Text = TableLabel &amp; " by Month"
      End With
  
      End Sub
  </code></pre>