Modified code on Post #6 :
Sub Test2()
Debug.Print vbCrLf & "Start at : " & Format$(Now, "HH:MM:SS")
Const uLimit = 25000
Dim cell As Range, a, b, f As Boolean, i As Long, t, u As Long, z As New Collection
With Sheets("List1")
a = .Range("B3:F" & .Cells(.Rows.Count, "B").End(xlUp).Row).Value
Set cell = .Range("J3")
End With
u = UBound(a, 1)
For i = 1 To u
z.Add Array(i, a(i, 1), "-" & a(i, 2) & "-" & a(i, 3) & "-" & a(i, 4) & "-", a(i, 5))
Next i
While z.Count
b = z(1)
z.Remove 1
f = False
For i = b(0) + 1 To u
If (InStrB(1, b(2), "-" & a(i, 2) & "-", vbBinaryCompare) + InStrB(1, b(2), "-" & a(i, 3) & "-", vbBinaryCompare) + InStrB(1, b(2), "-" & a(i, 4) & "-",
vbBinaryCompare)) = 0 Then
t = b(3) + a(i, 5)
z.Add Array(i, b(1) & "-" & a(i, 1), b(2) & (a(i, 2) & "-" & a(i, 3) & "-" & a(i, 4) & "-"), t)
f = True
If t >= uLimit Then Exit For
End If
Next i
If f = False Then
cell.Resize(, 3).Value = Array(b(1), Mid$(b(2), 2, Len(b(2)) - 2), b(3))
Set cell = cell.Offset(1)
End If
Wend
Debug.Print "Stop at : " & Format$(Now, "HH:MM:SS")
End Sub
Modified code on Post #12 :
Sub Test3()
Debug.Print vbCrLf & "Start at : " & Format$(Now, "HH:MM:SS")
Dim cell As Range, a, b, c, f As Boolean, i As Long, t, u As Long, z As New Collection
With Sheets("List1")
Set cell = .Range("O3")
'a = .Range("B3:D" & .Cells(.Rows.Count, "B").End(xlUp).Row).Value
a = .Range("B3:D4").Value
For i = 1 To UBound(a, 1)
z.Add Array(0, a(i, 1), "-" & a(i, 2) & "-", a(i, 3))
Next i
'a = .Range("H3:K" & .Cells(.Rows.Count, "H").End(xlUp).Row).Value
a = .Range("H3:K107").Value
u = UBound(a, 1)
End With
While z.Count
b = z(1)
z.Remove 1
f = False
For i = b(0) + 1 To u
If (InStrB(1, b(2), "-" & a(i, 2) & "-", vbBinaryCompare) + InStrB(1, b(2), "-" & a(i, 3) & "-", vbBinaryCompare) + InStrB(1, b(2), "-" & a(i, 4) & "-",
vbBinaryCompare)) = 0 Then
t = b(3) + a(i, 4)
z.Add Array(i, b(1) & "-" & a(i, 1), b(2) & (a(i, 2) & "-" & a(i, 3) & "-"), t))
f = True
If t >= uLimit Then Exit For
End If
Next i
If f = False Then
cell.Resize(, 3).Value = Array(b(1), Mid$(b(2), 2, Len(b(2)) - 2), b(3))
Set cell = cell.Offset(1)
End If
Wend
Debug.Print "Stop at : " & Format$(Now, "HH:MM:SS")
End Sub
Modified code on Post #14 :
Sub Test3()
Debug.Print vbCrLf & "Start at : " & Format$(Now, "HH:MM:SS")
Const uLimit = 25000
Dim cell As Range, a, b, f As Boolean, i As Long, t, u As Long, z As New Collection
With Sheets("List1")
'a = .Range("B3:E" & .Cells(.Rows.Count, "B").End(xlUp).Row).Value
a = .Range("B3:E22").Value
Set cell = .Range("J3")
End With
u = UBound(a, 1)
For i = 1 To u
z.Add Array(i, a(i, 1), "-" & a(i, 2) & "-" & a(i, 3) & "-", a(i, 4))
Next i
While z.Count
b = z(1)
z.Remove 1
f = False
For i = b(0) + 1 To u
If (InStrB(1, b(2), "-" & a(i, 2) & "-", vbBinaryCompare) + InStrB(1, b(2), "-" & a(i, 3) & "-", vbBinaryCompare)) = 0 Then
t = b(3) + a(i, 4)
z.Add Array(i, b(1) & "-" & a(i, 1), b(2) & (a(i, 2) & "-" & a(i, 3) & "-"), t)
f = True
If t >= uLimit Then Exit For
End If
Next i
If f = False Then
cell.Resize(, 3).Value = Array(b(1), Mid$(b(2), 2, Len(b(2)) - 2), b(3))
Set cell = cell.Offset(1)
End If
Wend
Debug.Print "Stop at : " & Format$(Now, "HH:MM:SS")
End Sub
Modified code on Post #16 :
Sub Test()
Const uLimit = 25000
Dim cell As Range, a, b, c, i As Long, j As Long, k As Long, isFound As Boolean, s1 As String, s2 As String, t
With Sheets("List1")
Set cell = .Range("M3")
'a = .Range("A1").CurrentRegion.Value
a = .Range("B1").CurrentRegion.Resize(20).Value
b = .Range("H1").CurrentRegion.Value
'b = .Range("H1").CurrentRegion.Resize(50).Value
For i = 3 To UBound(a, 1)
s1 = "-" & a(i, 2) & "-"
c = Split(a(i, 1), "-")
For j = 0 To UBound(c)
c(j) = "A" & c(j)
Next j
s2 = Join(c, "-")
For j = 3 To UBound(b, 1)
c = Split(b(j, 2), "-")
isFound = False
For k = 0 To UBound(c)
If InStrB(1, s1, "-" & c(k) & "-", vbBinaryCompare) Then
isFound = True
Exit For
End If
Next k
If Not isFound Then
t = a(i, 3) + b(j, 3)
c = Split(b(j, 1), "-")
For k = 0 To UBound(c)
c(k) = "B" & c(k)
Next k
cell.Resize(, 3).Value = Array(s2 & "-" & Join(c, "-"), a(i, 2) & "/" & b(j, 2), t)
Set cell = cell.Offset(1)
If t >= uLimit Then Exit For
End If
Next j
Next i
End With
End Sub
Bookmarks