i make mini calculation and need to round the result to the biggest quarter example :
if result 1.12 be 1.25 1.32 be 1.50 1.52 be 1.75 1.80 be 2.00
i make mini calculation and need to round the result to the biggest quarter example :
if result 1.12 be 1.25 1.32 be 1.50 1.52 be 1.75 1.80 be 2.00
You can find a good answer here (posted by sehe):
VBA: Round up to the nearest multiple of a number
For your need just change the type of the second paramter into double:
Public Function RoundUp(dblNumToRound As Double, lMultiple As Double) As Double
Check this example.You can use something like this:
to round to the biggest quarter you first add 0.24 and then round down to a quarter
to round down to a quarter you first multiply by 4, round the number down, and then divide by 4
'1 form with
' 1 textbox : Name=Text1
' 1 commandbutton : Name=Command1
Option Explicit
Private Sub Command1_Click()
Dim sngVal As Single
sngVal = Val(Text1.Text)
sngVal = sngVal + 0.24
sngVal = sngVal * 4
sngVal = Fix(sngVal)
sngVal = sngVal / 4
Caption = CStr(sngVal)
End Sub