在Excel中使用if语句对于十进制值 [英] Use if statement against the ones place decimal value in Excel

查看:184
本文介绍了在Excel中使用if语句对于十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助创建一个公式,将一个或多个1到6的数字舍入到最接近的5(例如276到275或131到130),并将任何其他数字舍入到最接近的倍数为5(例如277至280或132至135)。我认为逻辑看起来像这样:



= if(无法确定这个条件,天花板(A1,5),楼层(A1,5))

解决方案

可以使用 MROUND

  = MROUND(A1,5)

它绕到最近的5.包括和高于277.5的任何内容将四舍五入到280,而在下面的任何内容将被舍入到275。



如果你还想要使用 IF ,那么我会选择 MOD

  = IF(MOD(A1,5)> 2.5,CEILING(A1,5),FLOOR(A1,5))
/ pre>

所以,如果余数在2.5以上,除以5,则舍入,否则倒数。


I need help creating a formula that rounds a number with a 1 or 6 in the ones place down to the nearest multiple of 5 (e.g., 276 to 275 or 131 to 130) and rounds any other number up to the nearest multiple of 5 (e.g., 277 to 280 or 132 to 135). I figured the logic would look something like this:

=if(can't figure out this condition, ceiling(A1,5), floor(A1,5))

解决方案

You can use MROUND instead:

=MROUND(A1,5)

It rounds to the nearest 5. Anything including and above 277.5 will be rounded to 280, and anything below that will be rounded to 275.

If you still want to use IF, then I would pick MOD:

=IF(MOD(A1,5)>2.5, CEILING(A1,5), FLOOR(A1,5))

So, if the remainder is above 2.5 when divided by 5, round up, otherwise, down.

这篇关于在Excel中使用if语句对于十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆