Sub macro1() Start = Timer Dim i As Long, j As Long, string1_length As Long, string2_length As Long Dim distance(0 To 60, 0 To 50) As Long, smStr1(1 To 60) As Long, smStr2(1 To 50) As Long Dim min1 As Long, min2 As Long, min3 As Long, minmin As Long, MaxL As Long Data = Sheets("sheet1").Range("A2:M993549").Value For y = 2 To 993548 goodcallcounter = 0 bustedcallcounter = 0 string1 = Data(y, 2) freq1 = Data(y, 3) time1 = Data(y, 4) For Z = y - 1 To 1 Step -1 string2 = Data(Z, 2) freq2 = Data(Z, 3) time2 = Data(Z, 4) If Abs(time2 - time1) >= 26 Then Data(y, 6) = "?" Exit For Else End If If string1 = string2 And Abs(freq1 - freq2) <= 0.34 Then goodcallcounter = goodcallcounter + 1 If goodcallcounter = 1 Then g1 = Z If goodcallcounter = 2 Then g2 = Z End If If string1 = string2 And Abs(freq1 - freq2) >= 0.35 And Data(Z, 6) = "Good Call" Then Data(y, 6) = "Good Call, new freq?" Exit For Else End If If goodcallcounter = 2 Then Data(y, 6) = "Good Call" Data(g1, 13) = "Good Call" Data(g2, 13) = "Good Call" Exit For Else End If If Abs(freq1 - freq2) >= 0.35 Then Data(y, 6) = "?" GoTo a: End If ' Levenshtein3 will properly return a percent match (100%=exact) based on similarities and Lengths etc... string1_length = Len(string1): string2_length = Len(string2) distance(0, 0) = 0 For i = 1 To string1_length: distance(i, 0) = i: smStr1(i) = Asc(LCase(Mid$(string1, i, 1))): Next For j = 1 To string2_length: distance(0, j) = j: smStr2(j) = Asc(LCase(Mid$(string2, j, 1))): Next For i = 1 To string1_length For j = 1 To string2_length If smStr1(i) = smStr2(j) Then distance(i, j) = distance(i - 1, j - 1) Else min1 = distance(i - 1, j) + 1 min2 = distance(i, j - 1) + 1 min3 = distance(i - 1, j - 1) + 1 If min2 < min1 Then If min2 < min3 Then minmin = min2 Else minmin = min3 Else If min1 < min3 Then minmin = min1 Else minmin = min3 End If distance(i, j) = minmin End If Next Next MaxL = string1_length: If string2_length > MaxL Then MaxL = string2_length Levenshtein3 = 100 - CLng((distance(string1_length, string2_length) * 100) / MaxL) ' end Levenshtein calculation If Levenshtein3 > 50 And Levenshtein3 < 100 And Abs(freq1 - freq2) <= 0.11 And Data(Z, 6) <> "Busted" Then bustedcallcounter = bustedcallcounter + 1 If bustedcallcounter > 2 Then Data(y, 6) = "Busted" Data(y, 7) = Levenshtein3 Data(y, 8) = Z Data(y, 9) = string2 Data(y, 10) = freq2 Data(y, 11) = time2 Data(y, 12) = Data(Z, 5) Exit For Else Data(y, 6) = "?" End If a: Next Next Sheets("sheet2").Cells(y + 3, 1).Value = Timer - Start & " seconds " Sheets("sheet2").Cells(1, 2).Value = "#1" Sheets("sheet2").Cells(1, 3).Value = "call1" Sheets("sheet2").Cells(1, 4).Value = "freq1" Sheets("sheet2").Cells(1, 5).Value = "time1" Sheets("sheet2").Cells(1, 6).Value = "Spotter" Sheets("sheet2").Cells(1, 7).Value = "Quality tag" Sheets("sheet2").Cells(1, 8).Value = "Levenshtein %" Sheets("sheet2").Cells(1, 9).Value = "#2" Sheets("sheet2").Cells(1, 10).Value = "Call2" Sheets("sheet2").Cells(1, 11).Value = "Freq2" Sheets("sheet2").Cells(1, 12).Value = "time2" Sheets("sheet2").Cells(1, 13).Value = "Spotter2" Sheets("sheet2").Cells(1, 14).Value = "Quality after look back" Start = Timer For y = 1 To 993548 Sheets("sheet2").Cells(y + 1, 2).Value = Data(y, 1) Sheets("sheet2").Cells(y + 1, 3).Value = Data(y, 2) Sheets("sheet2").Cells(y + 1, 4).Value = Data(y, 3) Sheets("sheet2").Cells(y + 1, 5).Value = Data(y, 4) Sheets("sheet2").Cells(y + 1, 6).Value = Data(y, 5) Sheets("sheet2").Cells(y + 1, 7).Value = Data(y, 6) Sheets("sheet2").Cells(y + 1, 8).Value = Data(y, 7) Sheets("sheet2").Cells(y + 1, 9).Value = Data(y, 8) Sheets("sheet2").Cells(y + 1, 10).Value = Data(y, 9) Sheets("sheet2").Cells(y + 1, 11).Value = Data(y, 10) Sheets("sheet2").Cells(y + 1, 12).Value = Data(y, 11) Sheets("sheet2").Cells(y + 1, 13).Value = Data(y, 12) Sheets("sheet2").Cells(y + 1, 14).Value = Data(y, 13) Next Sheets("sheet2").Cells(y + 4, 1).Value = Timer - Start & " seconds " End Sub