1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Function stkr(code As String) As Variant
Dim y, z As Variant
If code Like "*Capspread*" Then
z = Split(code, " ")
y = Split(z(2), "/")
If z(2) Like "*%*" Then
stkr = Abs(ConvertNumérique(y(0)) - ConvertNumérique(y(1))) * 100
Else: stkr = Abs(ConvertNumérique(y(0)) - ConvertNumérique(y(1)))
End If
ElseIf code Like "*Floorspread*" Then
z = Split(code, " ")
y = Split(z(2), "/")
If z(2) Like "*%*" Then
stkr = -Abs(ConvertNumérique(y(0)) - ConvertNumérique(y(1))) * 100
Else: stkr = -Abs(ConvertNumérique(y(0)) - ConvertNumérique(y(1)))
End If
Else: stkr = " "
End If
End Function
Function ConvertNumérique(v) As Double
Dim N
N = Replace(v, "%", "")
N = Replace(N, ",", ".")
If IsNumeric(N) Then ConvertNumérique = N: Exit Function
N = Replace(N, ".", ",")
If IsNumeric(N) Then ConvertNumérique = N: Exit Function
End Function |
Partager