title: How to apply WorksheetFunction.CountIfs depending on time?
body: <p>I am trying to count records on Sheet2.</p>
  <pre class="lang-vb prettyprint-override"><code>Dim wksdata As Worksheet
  Dim xyz as String
  Dim Time as String
  
  Set wksdata = Sheets(&quot;Data&quot;)
  
  Time = Date + TimeValue(&quot;08:00:00&quot;) 'Set Time value as todays date 8am
  
  'set calculations worksheet cell I15 as the time value
  Worksheets(&quot;Calculations&quot;).Range(&quot;I15&quot;).Value = Time
  
  'converts time column to time format
  Worksheets(&quot;Data)&quot;).Range(&quot;U:U&quot;).NumberFormat = &quot;dd/mm/yyyy hh:mm:ss&quot;
  
  xyz = WorksheetFunction.CountIfs(wksdata.Range(&quot;I:I&quot;), &quot;xyz&quot;, _
    wksdata.Range(&quot;K:K&quot;), &quot;C&quot;, wksdata.Range(&quot;U:U&quot;), &quot;&lt;&quot; &amp; _
    Worksheets(&quot;Calculations&quot;).Range(&quot;I15&quot;).Value)
  </code></pre>
  <p>If I apply this directly in a worksheet it works with the same logic.</p>
  <p>Why isn't it working in VBA?</p>