简体   繁体   English

使用复杂条件在Excel公式中四舍五入

[英]Rounding in Excel Formula using complex conditions

Hi I need to round up the numbers (last 2 digits, no decimal) based on following conditions: 嗨,我需要根据以下条件将数字四舍五入(最后2位数字,无小数):

If from 0 to 64 should be 49 如果从0到64应该是49

If from 65 – 89 set at 79 如果从65 – 89设置为79

If from 90 – 129 set at 99 如果从90 – 129设置为99

If from 130 – 164 set at 149 如果从130 – 164设置为149

If from 165 – 189 set at 179 如果从165 – 189设置为179

If from 190 – 229 set at 199 如果从190 – 229设为199

and so on until 989 直到989

Then: If value is from 989 – 1099 set at 999 然后:如果值是从989 – 1099设置为999

If value is from from 1100 – 1249 set at 1199 如果值是从1100 – 1249设置为1199

If value is from from 1250 – 1349 set at 1299 如果值是从1250 – 1349设置为1299

If value is from from 1350 – 1449 set at 1399 如果值是从1350 – 1449设置为1399

and so on until 5000 直到5000

I would appreciate some info and help how to get a formula to work for this. 我会很高兴得到一些信息,并帮助您获取适用于此的公式。

Thanks Harmz 谢谢哈姆兹

This is not really a rounding problem but more a conversion problem. 这实际上不是一个舍入问题,而是一个转换问题。 because there seems to be no pattern to your number groups I don't think it is therefore something you can calculate and therefore you will have to do a lookup. 因为您的数字组似乎没有模式,所以我认为这不是可以计算的,因此您必须进行查找。

If you want to do it all in one formula you could use and array inside of a vlookup like the partial example below: 如果要在一个公式中完成所有操作,则可以在vlookup内部使用和数组,如下面的部分示例所示:

=VLOOKUP(C1,{0,49;65,79;90,99;130,149;165,179},2,TRUE)

Otherwise do it as a normal vlookup. 否则,将其作为普通的vlookup。 All you need is a two column table table, the first column contains the lower bound of you ranges and the second column contains the value that you want it to be. 您只需要一个两列表格表,第一列包含范围的下限,第二列包含您想要的值。 The important thing is that the vlookup has the final parameter of true, this makes the vlookup find the nearest match. 重要的是vlookup的最终参数为true,这使vlookup可以找到最接近的匹配项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM