title: Get last cell with data in column in excel 2007
body: <p>I'm trying to write a macro to create graphs in excel 2007.  I don't know the number of cells that will be in the range for one of the series of data (it could be anywhere from 50 - 1000).  I've googled this and I've found answers but they are all over the map and the few I've tried haven't helped me at all.  </p>
  
  <p>I'm a newb at vba macros but am an experienced programmer.</p>
  
  <p>I've found examples such as:</p>
  
  <pre><code>Sub FindLast2()
      x = ActiveSheet.UsedRange.Rows.Count
      ActiveCell.SpecialCells(xlLastCell).Select
  End Sub
  </code></pre>
  
  <p>I'm not sure if this works &amp; if it does work how would I incorporate that into my macro</p>
  
  <p>Here's my macro as it stands now:</p>
  
  <pre><code>Sub temp_graph_5()
  '
  ' temp_graph_5 Macro
  '
  
  '
      Sheets.Add After:=Sheets(Sheets.Count)
      Sheets(2).Select
      Sheets(2).Name = "Temperature"
      ActiveSheet.Shapes.AddChart.Select
      ActiveChart.ChartType = xlLine
      ActiveChart.SetSourceData Source:=Sheets(1). _
          Range("B2:B324")
      ActiveChart.SeriesCollection(1).Name = "=""Temperature"""
  
  End Sub
  </code></pre>
  
  <p>The 'B324' is the section that I need to be variable.</p>
  
  <p>Any help is greatly appreciated.</p>