“Network days function in Excel” can be translated to Chinese as “Excel中的工作日函数.”

huangapple go评论68阅读模式
英文:

Network days function in excel

问题

在Excel中,我想在另一个工作表上使用NETWORKDAYS函数。

这是我正在使用的公式。Details是表格名称

=NETWORKDAYS(Details[Date1],Details[Date2])

这个公式返回了一个#Value!错误。

如何在NETWORKDAYS函数中使用表格名称?

英文:

In Excel, I want to use the NETWORKDAYS function on a table in another sheet.

This is the formula I am using. Details is the table name

=NETWORKDAYS(Details[Date1],Details[Date2])

The formula is returning a #Value! error.

How can I use a table name in the NETWORKDAYS function?

“Network days function in Excel” can be translated to Chinese as “Excel中的工作日函数.”

答案1

得分: 1

源数据:Range vs Array

根据barry houdini的被接受答案,这个问题NETWORKDAYS函数接受arrays作为参数,但不接受ranges。我已经测试并确认这是正确的。

这解释了为什么您的公式失败,因为您尝试传递两个范围:Details[Date1]Details[Date2]。如果您首先将这两个范围转换为数组,NETWORKDAYS将成功输出一个值数组。

将范围转换为数组非常简单,只需对每个范围添加零,或者将范围相乘或相除:  +0*1,或 /1

新公式

=NETWORKDAYS(Details[Date1]+0,Details[Date2]+0)

<sub>公式示例</sub><br>
[<img src="https://i.stack.imgur.com/1GCbd.png" width="500" />](https://i.stack.imgur.com/1GCbd.png "点击放大")

<sub>测试包含范围和数组的参数</sub><br>
[<img src="https://i.stack.imgur.com/4elJv.png" width="500" />](https://i.stack.imgur.com/fLduy.png "点击放大")

关于空单元格的说明

  1. 在上述公式中,空单元格被解释为零
  2. NETWORKDAYS将零解释为1/0/1900的数值等效项
  3. 日期d的数值等效项可以通过计算d1/0/1900之间的天数来确定,后者等同于VALUE(d)的等效项
  4. 因此,如果两个参数单元格都为空,则NETWORKDAYS将返回0,如果其中一个单元格为空,仍将返回一个数字(取决于哪个参数为零)。
解决方法

解决方法是将零值(空单元格)强制转换为错误

  1. 如果提供给它的任何参数是错误的,NETWORKDAYS将返回一个错误
  2. 将一个数字n的倒数除以它的倒数将返回n,其中n&lt;&gt;0,但如果n=0,它将触发一个错误:1/(1/3)=31/(1/0)=#DIV/0!
  3. IFERROR会传递非错误,但如果检测到错误,它将允许不同的结果。在下面的公式中,备选结果是空白,&quot;&quot;,但它也可以轻松地是&quot;缺少参数&quot;
带解决方法的公式
=IFERROR(NETWORKDAYS(1/(1/Details[Date1]),1/(1/Details[Date2])),&quot;&quot;)
多行版本
=IFERROR(
  NETWORKDAYS(
    1/(1/Details[Date1]),
    1/(1/Details[Date2])),&quot;&quot;)
英文:

Source Data: Range vs Array

According to barry houdini's accepted answer to this question , the NETWORKDAYS function accepts arrays as arguments, but not ranges. I have tested and confirmed this to be the case.

This explains why your formula is failing as you are you trying to pass in two ranges: Details[Date1] and Details[Date2]. If you first convert the two ranges to arrays, NETWORKDAYS will successfully output an array of values.

It is simple enough to convert the ranges to arrays by adding zero to each range, or multiplying or dividing the ranges by one: &nbsp; +0 , *1 , or /1

New Formula

=NETWORKDAYS(Details[Date1]+0,Details[Date2]+0)

<sub>Formula Example</sub><br>
[<img src="https://i.stack.imgur.com/1GCbd.png" width="500" />](https://i.stack.imgur.com/1GCbd.png "click to enlarge")

<sub>Testing arguments containing Ranges vs. Arrays</sub><br>
[<img src="https://i.stack.imgur.com/4elJv.png" width="500" />](https://i.stack.imgur.com/fLduy.png "click to enlarge")

Note About Blank Cells

  1. In the formulas above, blank cells are interpreted as zero
  2. NETWORKDAYS will interpret zero as the numeric equivalent of 1/0/1900
  3. The numeric equivalent of a date d can be determined by counting the number of days between d and 1/0/1900 which is the equivalent of VALUE(d)
  4. As a result, NETWORKDAYS will return 0 if both the argument cells are blank, and will still return a number if one of the cells is blank (positive or negative depending on which argument is zero).
Workaround

The workaround is to coerce zero values (blank cells) to an error

  1. NETWORKDAYS will return an error if either argument provided to it is an error
  2. Dividing one by the inverse of a number n will return n where n&lt;&gt;0 but if n=0 it will trigger an error: 1/(1/3)=3 but 1/(1/0)=#DIV/0!
  3. IFERROR will pass non-errors, but allow a different result if it detects an error. In the formula below the alternative result is blank, &quot;&quot;, but it could easily be &quot;Argument(s) Missing&quot;
Formula with Workaround
=IFERROR(NETWORKDAYS(1/(1/Details[Date1]),1/(1/Details[Date2])),&quot;&quot;)
Multi-Line Version
=IFERROR(
  NETWORKDAYS(
    1/(1/Details[Date1]),
    1/(1/Details[Date2])),&quot;&quot;)

huangapple
  • 本文由 发表于 2023年5月25日 04:44:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76327285.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定