Вы можете создать очень быстрый массовый счет со словарем. Зацикливание массива вместо повторных чтений с рабочего листа ускоряет процесс.
Option Explicit
Sub num_and_num_count()
Dim i As Long, j As Long, m As Long, n As Long, cmbo As String
Dim arr As Variant, nums As Object
Set nums = CreateObject("scripting.dictionary")
With Worksheets("sheet5")
arr = .Range(.Cells(2, "A"), .Cells(.Rows.Count, "F").End(xlUp)).Value2
For i = LBound(arr, 1) To UBound(arr, 1)
For j = LBound(arr, 2) To UBound(arr, 2)
For m = LBound(arr, 1) To UBound(arr, 1)
For n = LBound(arr, 2) To UBound(arr, 2)
If arr(i, j) < arr(m, n) Then
cmbo = Format(arr(i, j), "00") & Format(arr(m, n), "00") & _
Join(Array(arr(i, j), arr(m, n)), Chr(38))
nums.Item(cmbo) = nums.Item(cmbo) + 1
End If
Next n
Next m
Next j
Next i
.Cells(1, "H").Resize(1, 2) = Array("combinations", "count")
.Cells(2, "H").Resize(nums.Count, 1) = Application.Transpose(nums.keys)
.Cells(2, "I").Resize(nums.Count, 1) = Application.Transpose(nums.items)
With .Range(.Cells(2, "H"), .Cells(.Rows.Count, "I").End(xlUp))
.Sort key1:=.Cells(1), order1:=xlAscending, Header:=xlNo
.Columns(1).TextToColumns Destination:=.Cells(1), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 9), Array(4, 1))
End With
End With
End Sub
