In the following code, the code stores the values in column B-C-D-E in a collection named "Numbers" then subtract each number from the other and put the results in column L
Code: Select all
Sub StepA()
Dim t As Double: t = Timer
With ThisWorkbook.Worksheets(1)
.Range("L:L").ClearContents
Dim Numbers As New Collection
Dim i As Integer, j As Integer
i = 2: j = 2
Dim temp As Double
Dim emptyNo As Byte
Do Until emptyNo >= 20
For j = 2 To 5
temp = .Cells(i, j).Value
If temp <> 0 Then
Numbers.Add (temp)
emptyNo = 0
Else
emptyNo = emptyNo + 1
End If
Next j
i = i + 1
Loop
Dim k As Long
k = 3
.Cells(2, 12) = "Value "
For i = 1 To Numbers.Count
For j = 1 To Numbers.Count
If i <> j Then .Cells(k, 12) = Abs(Numbers(i) - Numbers(j)): k = k + 1
Next j
Next i
End With
Debug.Print Timer - t
End Sub