I did a quick search and didn't find any VBA equivalents forExcel's FLOOR and CEILING functions. However, you can use someother simple functions to create the same effect. See the exampleequations below.
Eq1: "a" = 4.1 Eq2: "x" = int("a") '=4 Eq3: "y" = iif("a" - "x" > 0, "x" + 1, "a") '=5
"x" will always be the number "a" without any fractional component(4). "y" will always be "a" rounded up to the next whole number(5). If "a" is a whole number, a=x=y.
SF
SF2008-02-08
There is a ROUNDUP function in EXCEL but it looks like itdoesn't work in equations. If should work if you use a designtable.
SF
SF2008-11-27
add a equation ex. value=round(7/3) evaluates to 2
or value=round(7/3,2) evaluates to 2.33
SF
SF2010-09-03
What if I want to round off to the nearest 10.
Let say 168.3 and the output should be 170?
What will be the formula?
JB
JB2010-09-03
Hint- Study Mahir's post and understand it. The answer should come to you.
Edit - I missed that it was nearest 10, not FLOOR.
10*round(x/10) where 'x' is your number.
GL
GL2019-11-25
Hi Folks,
This is how I have been achieving rounding DOWN to the nearest increment using INT, and I use ROUND to round UP.
=( int((int("target value to round"))/10))*10
In this case it is rounding DOWN to nearest "10". To round down to nearest "5" just change the 10 in two places to 5 eg.
=( int((int("target value to round"))/5))*5
To round UP to nearest increment substitute "INT" with "ROUND"
Eq1: "a" = 4.1
Eq2: "x" = int("a") '=4
Eq3: "y" = iif("a" - "x" > 0, "x" + 1, "a") '=5
"x" will always be the number "a" without any fractional component(4). "y" will always be "a" rounded up to the next whole number(5). If "a" is a whole number, a=x=y.
or value=round(7/3,2) evaluates to 2.33
What if I want to round off to the nearest 10.
Let say 168.3 and the output should be 170?
What will be the formula?
Hint- Study Mahir's post and understand it. The answer should come to you.
Edit - I missed that it was nearest 10, not FLOOR.
10*round(x/10) where 'x' is your number.
Hi Folks,
This is how I have been achieving rounding DOWN to the nearest increment using INT, and I use ROUND to round UP.
=( int((int("target value to round"))/10))*10
In this case it is rounding DOWN to nearest "10". To round down to nearest "5" just change the 10 in two places to 5 eg.
=( int((int("target value to round"))/5))*5
To round UP to nearest increment substitute "INT" with "ROUND"
=( round((round("target value to round"))/10))*10
Enjoy!!