My actual calculation is:
1. Calculate the minimum value according to the above requirements.
2. Calculate the maximum value according to the same principle.
3. Put the maximum/minimum value of categories 6, 7, 8 and 9 respectively.
4. Select the minimum value of the four ratios
This outputs the minimum ratio of each row to the table.Other intermediate data is not output.
I wrote the code in Excel's VBA.
Sub vba()
ar = Range("d2:d" & Cells(Rows.Count, "d").End(3).Row)
ReDim br(1 To UBound(ar), 1 To 8): ReDim cr(1 To UBound(ar), 1 To 1)
For r = 10 To UBound(ar)
n = 99: m = 0
For c = 0 To 8
If ar(r - c, 1) < n Then n = ar(r - c, 1)
If ar(r - c, 1) > m Then m = ar(r - c, 1)
If c > 4 Then br(r, c - 4) = n: br(r, c) = m
Next
Next
Cells(2, "G").Resize(UBound(br), UBound(br, 2)) = br
For r = 10 To UBound(ar)
For c = 1 To 4
If c = 1 Then
cr(r, 1) = br(r, c + 4) / br(r, c)
Else
If br(r, c + 4) / br(r, c) < cr(r, 1) Then cr(r, 1) = br(r, c + 4) / br(r, c)
End If
Next
Next
Cells(2, "f").Resize(UBound(br), 1) = cr
End Sub
How do I change this VBA to JSL?
Thanks!