简体   繁体   English

在Excel中使用OR函数时出错

[英]Error using OR function in Excel

I am using Excel Formula OR in an Excel formula and am little surprised the way it is behaving. 我在Excel公式中使用Excel公式OR ,对它的行为方式并不感到惊讶。

I am using the following Excel formula : 我正在使用以下Excel公式:

=IF(OR(ISERROR(funct(A1:A5)), funct(A1,A5)=0), "ERROR", funct(A1,A5))

My understanding was that, if ISERROR(funct(A1:A5)) True(or False) , the result of OR operation would be True(or False). 我的理解是,如果ISERROR(funct(A1:A5)) True(or False) ,则OR运算的结果为True(或False)。

In my experiment, I was expecting the answer to be "ERROR" as the ISERROR(funct(A1:A5)) results in true . 在我的实验中,我期望答案是“ ERROR”,因为ISERROR(funct(A1:A5))结果为true

But I am getting #VALUE! 但是我得到#VALUE! error. 错误。 Any Idea what could be wrong. 任何想法可能有什么问题。 Or if I can rephrase the formula to make it work. 或者,如果我可以改写公式以使其起作用。

Thanks 谢谢

=IF(ISERROR(funct(A1:A5)),"ERROR",IF(funct(A1:A5)=0,"ERROR",funct(A1:A5)))

I recommend Tim's answer but if func() is a large function, as you say, then you might want to minimise the number of times it's used. 我推荐蒂姆的答案,但是,正如您所说的,如果func()是一个大函数,那么您可能希望最大程度地减少使用它的次数。 I'm assuming that the same function should be invoked throughout the formula, ie func(A1:A5) 我假设在整个公式中都应调用相同的函数,即func(A1:A5)

In Excel 2007 or later you could use IFERROR function: 在Excel 2007或更高版本中,您可以使用IFERROR函数:

=IFERROR(IF(func(A1:A5)=0,"ERROR",func(A1:A5)),"ERROR")

or in earlier versions you could force func(A1:A5) to give an error when equal to zero by dividing 1 by func(A1:A5): 或在较早版本中,您可以通过将1除以func(A1:A5)来强制func(A1:A5)在等于零时给出错误:

=IF(ISERROR(1/func(A1:A5)),"ERROR",func(A1:A5))

Edit: Taking that one step further you could combine both of those approaches in Excel 2007 or later so that you only need to call func once: 编辑:更进一步,您可以在Excel 2007或更高版本中结合使用这两种方法,因此只需要调用一次func:

=IFERROR(1/(1/func(A1:A5)),"ERROR")

I think you're missing a close bracket. 我认为您缺少一个括号。

Try this: 尝试这个:

=IF(OR(ISERROR(funct(A1:A5)), func(A1,A5)=0), "ERROR", func(A1,A5))

=IF(OR(ISERROR(funct(A1:A5)), funct(A1,A5)=0), "ERROR", func(A1,A5)) - close look at your formula resulted in the suggestion: funct(A1,A5)=0 and func(A1,A5) are really different functions, or this is a typo in your formula? =IF(OR(ISERROR(funct(A1:A5)), funct(A1,A5)=0), "ERROR", func(A1,A5)) -仔细查看您的公式得出以下建议: funct(A1,A5)=0func(A1,A5)确实是不同的函数,还是您的公式中有错字 Perhaps that's the case. 也许是这样。

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

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