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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
Option Explicit
Sub CorrigerErreur_de_STEP()
'Auteur Docmarti 24/08/2014
Dim Rise As Double, debut As Double, fin As Double
Dim nb As Long, i As Double
Dim places As Long
places = 14
debut = -0.6
fin = 1.91
Rise = 0.01
nb = 0
For i = debut To fin Step Rise
nb = nb + 1
Cells(nb, 4) = i
i = dmwSymArithRoundUp(i, places)
If i <> Cells(nb, 4) Then
Cells(nb, 5) = i
Cells(nb, 6) = Cells(nb, 4) - i
End If
Next
Cells(nb, 5) = fin
Cells(nb + 1, 5) = i
Cells(nb, 4).Select
i = dmwSymArithRoundUp(i, places)
If i < fin Then
nb = nb + 1
Cells(nb, 4) = i
End If
End Sub
Function dmwSymArithRoundUp(ByVal Number As Variant, ByVal places As Integer) _
As Double
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Note: Symmetric arithmetic rounding
' Positive and negative numbers move away from 0
' .5s rounded up
' Author: David Wallis (DMW Consultancy Limited)
' Date: 28 Aug 1997
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim dblTemp As Double
'dblTemp = CDec(Nz(Number))'Modification by Docmarti
dblTemp = IIf(Number = Empty, 0, Number) 'Added by Docmarti
dblTemp = CDec(dblTemp * 10 ^ places)
dmwSymArithRoundUp = Fix(dblTemp + 0.5 * Sgn(Number)) / 10 ^ places
End Function |