仅从单元格值中获取数字

时间:2019-05-07 07:03:40

标签: excel excel-formula

我使用公式将3 hours 7 mins显示为3,07。但是,由于某些原因,相同的公式在Win7 Office 2013英文版上不起作用,显示为#VALUE。为什么会这样以及如何修复呢?也许其他公式都适合?

Windows 10 Office 365欧洲版

=CEILING(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISERROR(SEARCH("hour"; R96)); "0 hours "; "")&R96;"s";"");" min";"");" hour ";",");0,1)

Windows 7 Office 2013英文版

=CEILING(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISERROR(SEARCH("hour", P96)), "0 hours ", "")&P96,"s","")," min","")," hour ",","),0.1)

2 个答案:

答案 0 :(得分:1)

3,7不是数字,因此当公式达到此点时:

=CEILING("3,7",0.1)

您将收到#VALUE错误。您可以改用以下命令使其正常工作(注意更改):

=CEILING(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISERROR(SEARCH("hour", P96)), "0 hours ", "")&P96,"s","")," min","")," hour ","."),0.1)
                                                                                                                            ^

这将产生3.7。如果需要使用逗号,则需要最后一个SUBSTITUTE

=SUBSTITUTE(CEILING(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISERROR(SEARCH("hour", P96)), "0 hours ", "")&P96,"s","")," min","")," hour ","."),0.1), ".", ",")

答案 1 :(得分:1)

这似乎是Decimal separator在不同国家/地区之间引起的问题:有些人将“ 1000一半”写为“ 1,000.5”,而另一些人将其写为“ 1.000,5”

因此,您需要确保","知道何时应改为"."。为此,我想到的最简单的方法是MID(1/2,2,1)-也就是说,将中间字符取一半。根据您的设置,该值为0.5(结果:".")或0,5(结果:","

({em末尾的0.1应该在版本之间自动更改,因为它是实际数字-如果不是,则将其更改为1/10,以获得类似的结果)

=CEILING(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISERROR(SEARCH("hour"; R96)); "0 hours "; "")&R96;"s";"");" min";"");" hour ";MID(1/2,2,1));1/10)

还要考虑:您当前的系统将“ 2小时1分钟”写为“ 2,1”(或“ 2.1”,具体取决于设置)-但是,它也会 写“ 2小时10分钟”作为“ 2,1”。您的要求可能需要审核