一元加号运算符在 Excel 公式中的作用是什么? [英] What does the unary plus operator do in Excel formulas?
问题描述
这个看似微不足道的操作在公式中的许多情况下都很有用:
This seemingly trivial operation can be useful in a number of situations within formulas:
A.否则会抛出错误的函数:
A. functions that would otherwise throw an error:
QUOTIENT(+A1:A3,4)
WORKDAY(+A1:A3,7)
B.将范围转换为数字 - 即任何文本为零:
B. converting a range to numbers - i.e. any text to zero:
N(+A1:C3)
C.从不同的工作表返回一组混合数据:
C. returning an array of mixed data from different sheets:
CELL("contents",IF(1,+INDIRECT({"Sheet1!A1","Sheet2!B2","Sheet3!C3"})))
我对此的发现很少 - 也许这是一个新发现.
I have found very little on this - perhaps this is a new finding.
这个问题部分是为了兴趣,部分是为了看看是否有人可以进一步阐明或找到其他可能的应用程序 - excel 或 vba 相关?
This question is in part for interests' sake and in part to see if anyone can shed further light or find other possible applications - excel or vba related?
推荐答案
在其中一些示例中,例如对于WORKDAY
和QUOTIENT
,+
将范围 转换为数组
In some of those examples, e.g. for WORKDAY
and QUOTIENT
, the +
is converting a range to an array
许多旧的Analysis ToolPak
函数,如WORKDAY
、NETWORKDAYS
、WEEKNUM
等将不接受范围 作为参数,但在 Excel 2007
或更高版本的 excel 版本中,他们将接受 array 作为参数 - 使用 +0
或 --
(或显然 +)会将范围转换为数组,因此在 Excel 2007 中,如果您使用这样的公式:
Many of the old Analysis ToolPak
functions like WORKDAY
, NETWORKDAYS
, WEEKNUM
etc. won't accept a range as an argument, but in Excel 2007
or later excel versions they will accept an array as an argument - using +0
or --
(or apparently +) will convert the range to an array, so in Excel 2007 if you use a formula like this:
=AVERAGE(WEEKNUM(A1:A3))
其中 A1:A3 包含日期
where A1:A3 contain dates
....它会返回一个错误
....it will return an error
但是这个版本(使用 CTRL+SHIFT+ENTER 输入的数组)将提供周数的平均值:
but this version (array entered with CTRL+SHIFT+ENTER) will work to give you the average of the week numbers:
=AVERAGE(WEEKNUM(+A1:A3))
这篇关于一元加号运算符在 Excel 公式中的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!