title: Object defined error when defining variable as sum of the values in a column
body: <p>I put together part of a script that will delete the last row if the sum of a set of values matches the total at the last row of that column.  However I am receiving an object defined application error when running the following:</p>
  
  <pre><code>
  Dim number As Double
  Dim lRow As Long
  
  lRow = Cells(Rows.Count, 36).End(xlUp).Row
  
  number = Application.WorksheetFunction.Sum(Range(Cells(1, 36), Cells(lRow - 1, 36)))
  
  If number = lRow Then
  
  Cells(Rows.Count, 1).End(xlUp).Delete
  End If
  </code></pre>
  
  <p>This seems to work with <code>If number = range("A1")</code> as a test but not with these variables.
  Thanks</p>