title: Excel 2010 crashes when using VBA
body: <p>I am trying to code a bit of VBA to compare a date from one column to the dates in another column. My code is:</p>
  <pre class="lang-vb prettyprint-override"><code>Sub ForLoop()
  
      Dim i As Integer
      Dim j As Integer
      Dim homenum As Integer
      Dim dif As Long
      Dim clockin As Long
      Dim clockout As Long
  
      For i = 2 To 18418
  
          clockin = Cells(i, 4).Value
          homenum = Cells(i, 5).Value
          dif = 100
  
          For j = 2 To 18418
              clockout = Cells(j, 6).Value
              If Cells(j, 5).Value = homenum &amp; Abs((clockin - clockout) * 24 * 60) &lt; Abs(dif) Then
                  dif = Abs((clockin - clockout) * 24 * 60)
              End If
          Next j
  
          Cells(i, 9).Value = Abs(dif)
      Next i
  End Sub
  </code></pre>
  <p>Whenever I try to run this, Excel crashes, and I end up having to end the program from Task Manager. I can't find any reason for that in my code. Does anyone have any ideas?</p>
  <p>A quick example of the input I'm working with:</p>
  <p><a href="https://i.stack.imgur.com/jc4Dx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jc4Dx.png" alt="enter image description here" /></a></p>