I have 2 nested loops in an array but as far as I understand I need third which I am not able to implement.
I have following data (in yellow):
Current code calculates as indicated in column Actual Behavior:
Dim arr, outarr as Variant
Dim lastc, lastr as long
lastc = 2
lastr = Cells(ws.Rows.count, lastc).End(xlUp).Row
arr = Range(Cells(2, lastc), Cells(lastr, lastc))
cnt = ((UBound(arr, 1) - 1) * UBound(arr, 1)) / 2
k = 1
ReDim outarr(1 To cnt, 1 To 1)
For i = LBound(arr, 1) + 1 To UBound(arr, 1)
For j = LBound(arr, 1) To i - 1
outarr(k, 1) = arr(j, 1) - arr(i, 1)
k = k + 1
Next j
Next i
Desired behavior would be for values from 1.1 to 6.1 to store minimum value in that range as a result. 10 - 0 = 10 but I need actual minimum value in that range (1.6 to 6.6) and minimum value would be 10 - 40 = -30.
It's really important that minimum value is always calculated as first value of a range - X value of a range. First value in given loop is a constant.
I believe that third loop is needed to store minimum value and then insert this value to outarr but I've not been successful yet.
Thank you for your help.



B7-B3, won't the minimum value be5 - 40? andB7-B2, the minimum value would be0 - 40?B5-B3, the output is 25 but isn't the minimum30 - 40?