title: VBA If time is between two times
body: <pre><code>i = 1    
  For Each cell In Range("D1:D10000")
    If IsEmpty(cell.Value) Then Exit For
  
    Select Case Range("N" &amp; i).Value
      Case 0 To 40
        startTime  = "13:00"
      Case 40 To 60
        secondTime = Range("V" &amp; i).Value
      Case 60 To 100
        finalTime = Range("V" &amp; i).Value
      Case Else
  
     End Select
  
    Dim startTime As Date
    Dim secondTime As Date
    Dim finalTime As Date
    Dim timeRef As Date
    timeRef = Range("V" &amp; i).Value
  
    If timeRef &gt;= startTime And timeRef &lt; secondTime Then 
  
    ElseIf timeRef &gt;= secondTime And timeRef &lt; finalTime Then
  
    ElseIf timeRef &gt; finalTime Then
  
    End If
    i = i + 1
  Next
  </code></pre>
  
  <p>Ok, So i'm using the above to try and compare times which are formatted as Dates. They are all fetched from a worksheet which is Custom Formatted as "hh:mm" but I cannot seem to get times to fall within any but the final <code>elseif</code></p>
  
  <p>Argh!</p>