title: Type mismatch (Error 13) when using Sumifs
body: <p>I want to add the value of all the cells in column Q that has a date between Now and thirty minutes ago in column Z AND has a certain name in column Y.</p>
  
  <pre><code>dim nu as Date
  dim ThirtyMinAgo as Date
  dim currentBestTopThree as Integer
  
  nu = WorksheetFunction.RoundDown(Now * 48, 0) / 48
  ThirtyMinAgo = nu - 1 / 48
  
  currentBestTopThree = _
      Application.SumIfs(Sheets("topthreecheck").Range("Y2:Y" &amp; Rows.Count).End(xlUp).Row, employeelist(i), _
       Sheets("topthreecheck").Range("Z2:Z" &amp; Rows.Count).End(xlUp).Row, "&lt;" &amp; nu, _
       Sheets("topthreecheck").Range("Z2:Z" &amp; Rows.Count).End(xlUp).Row, "&gt;=" &amp; ThirtyMinAgo, _
       Sheets("topthreecheck").Range("Q2:Q" &amp; Rows.Count).End(xlUp).Row)
  </code></pre>
  
  <p><code>employeelist(i)</code> is an array that contains all the unique names in column Y.</p>
  
  <p><code>i</code> is the current iteration of an <code>For</code> loop that loops between <code>1 and Ubound(employeelist)</code></p>
  
  <p>Column Z contains dates formatted as "2020-03-01 08:32:23"</p>
  
  <p>Column Y contains names</p>
  
  <p>Column Q contains numbers</p>
  
  <p>The SumIfs line gives me the error </p>
  
  <blockquote>
    <p>Type Mismatch(Error 13)</p>
  </blockquote>
  
  <p>I tried to hard code a date:</p>
  
  <pre><code>currentBestTopThree = Application.SumIfs(Sheets("topthreecheck").Range("Z2:Z" &amp; Rows.Count).End(xlUp).Row, #2/25/2020 9:30:00 AM#, _
  Sheets("topthreecheck").Range("Q2:Q" &amp; Rows.Count).End(xlUp).Row)
  </code></pre>
  
  <p>But it still shows the error.</p>
  
  <p>I also tried:</p>
  
  <pre><code>If Sheets("topthreecheck").Range("Z2") = #2/25/2020 9:30:00 AM# Then
  End If
  </code></pre>
  
  <p>And that line doesn't give me the Type Mismatch error.</p>
  
  <p>Anyone knows what's going on here?</p>
  
  <p>It's as if the code tries to sum the dates. I guess that's why it gives the error. Since <code>currentBestTopThree</code> is an integer. But I've tried both </p>
  
  <p><code>SumIfs(Sum_range, Range1, Criteria1)</code> and </p>
  
  <p><code>SumIfs(Range1, Criteria1, Sum_range)</code></p>
  
  <p>One of them should be the right one!</p>