title: Code to compare each cell in a column to every cell in another column
body: <p>I have two columns with random times and the times come from two different sources so the columns do not have the same amount of data points.  I want to start with the first time in the first column and compare it to each time in the second column.  If there is a match in times, I would like to pull relevant data. After a match is found (if there is one) I would like for the code to go to the second cell in the first column and compare it to every value in the second column and so on.</p>
  
  <p>Here is the code I have so far:</p>
  
  <pre><code>Sub TransferInfo()
  
  'Activate the Sub to Convert and Format Dates
  Call ConvertDates
  
  'Define Variables
  Dim st As Worksheet
  Dim ts As Worksheet
  Dim lastrow As Long
  Dim i As Integer
  j = 2
  
  'Find and set the last used row
  Set st = ThisWorkbook.Worksheets("Data Table")
  lastrow = st.Cells(st.Rows.Count, "B").End(xlUp).Row
  Set ts = ThisWorkbook.Worksheets("ShopFloor")
  
  'Cycle through/compare Row J, Column 18 based on each cell in Row I, Column 14
  For i = 2 To lastrow
      Do Until IsEmpty(ts.Cells(j, 8)) Or IsEmpty(st.Cells(j, 2))
          If st.Cells(i, 14).Value = ts.Cells(j, 18).Value Then  
      st.Cells(i, 15).Value = ts.Cells(j, 2).Value
      Exit Do
      Else
      st.Cells(i, 15).Value = ""
      End If
      j = j + 1
    Loop
  j = 2
  Next i
  
  End Sub
  </code></pre>
  
  <p>The other sub that I call at the beginning of this sub simply rounds the times in each column to the nearest 15 minute interval to increase the likelihood of matches between the columns.</p>
  
  <p>My question is: The code does not copy and paste any more information although there are times that match between the two columns.  Why would the code that I have not work?  Also, with larger data sets I am afraid that this the code may crash Excel and because I have a loop within a loop trying to process a lot of data a lot of times, but I don't know of a more efficient way to accomplish what I am trying to without this code.</p>
  
  <p>If anyone has any insights as to why this code doesn't work I would greatly appreciate any help.</p>
  
  <p>Thanks!</p>