📜  Excel 中的 IFERROR函数示例

📅  最后修改于: 2021-09-23 05:07:44             🧑  作者: Mango

Excel 是一种有用的数据处理工具,在世界范围内被广泛使用。内置功能使该应用程序更加用户友好。这样的函数就是IFERROR函数。此函数有助于在使用公式时捕获和处理错误(例如将某些内容除以“0”)。此函数对 Excel 用户非常有用。

这个函数完全按照它的名字工作。它返回自定义结果或用户指定的值,如果发生“错误” 。否则,它返回指定函数或公式生成的结果。此函数用于处理所有类型的 Excel 错误,包括#DIV/0!、#N/A、#NAME?、#NULL!、#NUM!、#REF! 和 #VALUE!错误。

句法:

IFERROR(value, value_if_error)

这里, value_if_error参数可能是 NULL 或 Null 字符串 。

参数:

  • 值(必需):这是 IFERROR函数将检查错误的值、函数或引用。此参数必须由用户提供。
  • value_if_error(Required):这个参数也由用户提供。如果发现错误,IFERROR 将返回此值或文本或数字。此参数可以是空字符串或 null。

返回值:如果发现错误,此函数将返回 value_if_error 参数的内容。否则,它返回指定公式或函数的标准结果。
根据 value_if_error 参数的内容,此函数可能会用其他一些值、一些文本、逻辑值或另一个公式或函数的一些结果替换错误值。如果发生错误且未提供 value_if_error 参数,则此函数返回“0”。如果值是一个数组,则此函数返回一个结果数组,其中包含每个单元格的结果。

例子:

  • 当提供 value_if_error 参数时:
Value 1 Value 2  IFERROR function Result Remarks
25 5 =IFERROR(A2/B2, “Error”) 5 No error occurs here, so the function returns the result “A2/B2”.
35 7 =IFERROR(A3/B3, “Error”) 5 No error occurs here, so the function returns the result “A3/B3”.
23 0 =IFERROR(A4/B4, “Error”) Error The error occurs while trying to divide by ‘0’. So the function returns the text in the value_if_error argument.
N/A 25 =IFERROR(A5/B5, “Error”) Error An error occurs as value 1 is not valid(N/A). So, again it returns the text in the value_if_error argument.
  3 =IFERROR(A6/B6, “Error”) 0 No error occurs here though the value 1 cell is blank. The function accepts this as ‘0’ and returns the result.

输出:

输出Excel截图

  • 当未提供 value_if_error 参数时:

基本上在这种情况下,函数将返回零。

value 1 value 2 IFERROR function Result Remarks
25 5 =IFERROR(A2/B2, ) 5 No error occurs here, so the function returns the result “A2/B2”.
35 7 =IFERROR(A3/B3, ) 5 No error occurs here, so the function returns the result “A3/B3”.
23 0 =IFERROR(A4/B4, ) 0 The error occurs while trying to divide by ‘0’. So the function returns ‘0’ as the value_if_error argument is absent.
N/A 25 =IFERROR(A5/B5, ) 0 An error occurs as value 1 is not valid(N/A). So, again it returns ‘0’ as the value_if_error argument is absent.
  3 =IFERROR(A6/B6, ) 0 No error occurs here though the value 1 cell is blank. The function accepts this as ‘0’ and returns the result.

输出:

输出Excel截图