title: How to specify a sheet to determine 'lastrow'?
body: <p>I am trying to determine 'lastrow' of the sheet that the macro is being run on.</p>
  
  <p>I am working with two sheets. Sheet1 has about 150 rows of data and Sheet 2 only has two.</p>
  
  <p>I expected that when I selected Sheet2 and assigned lastrow that it would take the count of rows from Sheet2, instead it is storing the row count from sheet1.</p>
  
  <pre><code>sub row_count()
  dim lastrow as long
  lastrow = Range("A" &amp; Rows.Count).End(xlUp).row
  
  if lastrow = 150 then
      with sheets("sheet2")
          .select
          lastrow = Range("A" &amp; Rows.Count).End(xlUp).row
          msgbox lastrow '&lt;----- Always returns the value of sheet1 instead of sheet2.
      end with
  
  end sub
  </code></pre>