title: How do I count employees who work per hour including midnight using VBA?
body: <p>I need to count the number of employee who work in a particular hour:</p>
  
  <p>For ex: My shift is 11:00pm to 8:00am, and I'm looking for the number of employees who's working within 11:00pm to 12:00am. My current shift is within the provided time (1 hour). If I'm looking for 8:00am to 9:00am and my shift is not within the provided time, then no count for me.</p>
  
  <p>The problem is the formula doesn't counting time that passes midnight.</p>
  
  <p>I tried several formulas and converted it into VBA code, but I failed. Here's the formula that I recently converted to code:</p>
  
  <p><code>=COUNTIFS(B$2:B$7,"&lt;"&amp;F9,C$2:C$7,"&gt;"&amp;E9)</code></p>
  
  <p>and</p>
  
  <p><code>=SUMPRODUCT(--(B2:B7&lt;F2),--(C2:C7&gt;F1))</code></p>
  
  <p>Any ideas?</p>