title: Count number of rows in a different Excel Sheet
body: <p>It is in the same workbook. I have a few numbers in a range in Sheet3 and the button is in Sheet2. I want it to count the number of rows and then return the value to me in a msgbox. If I run this with the Sheet3 open it runs fine. If I run it with a different sheet active I get an object error for the counting part. It does insert the 3 in cell A2 no matter what sheet is active. </p>
  
  <pre><code>Sub problem3run()
  Dim rngtest As Range
  
  Set rngtest = Sheet3.Range("A2")
  
  rngtest.Value = 3
  
  Dim rngacount As Integer
  rngacount = Sheet3.Range(Range("A4"), Range("A4").End(xlDown)).Rows.Count
  
  MsgBox (rngacount)
  
  End Sub
  </code></pre>
  
  <p>What is messed up in this?</p>