一元加算子在Excel公式中做了什么? [英] What does the unary plus operator do in Excel formulas?
问题描述
这个看似简单的操作可以在公式中的许多情况下使用:
A 。否则会产生错误的功能:
QUOTIENT(+ A1:A3,4)
工作日(+ A1: A3,7)
B 。将范围转换为数字 - 即任何文本为零:
N(+ A1:C3)
C 。从不同的表格返回一组混合数据:
CELL(contents,IF(1,+ INDIRECT({Sheet1 !A1,Sheet2!B2,Sheet3!C3})))
发现这很少 - 也许这是一个新的发现。
这个问题部分是为了兴趣,部分原因是为了看看有没有人能够进一步发现或找到其他可能的应用程序 - excel或vba相关?
在这些例子中,例如对于 WORKDAY
和 QUOTIENT
, +
正在转换范围到数组
许多旧的 Analysis ToolPak
功能像 WORKDAY
, NETWORKDAYS
, WEEKNUM
等赢得不接受范围作为参数,但在 Excel 2007
或更高版本的excel版本中,他们将接受数组作为一个参数 - 使用 +0
或 -
(或显然是+)将将范围转换为数组,因此Excel 2007如果您使用这样的公式:
= AVERAGE(WEEKNUM(A1:A3))
p>
其中A1:A3包含日期
....它将返回错误
但是这个版本(使用 CTRL + SHIFT + ENTER 输入的数组)周号:
= AVERAGE(WEEKNUM(+ A1:A3))
This seemingly trivial operation can be useful in a number of situations within formulas:
A. functions that would otherwise throw an error:
QUOTIENT(+A1:A3,4)
WORKDAY(+A1:A3,7)
B. converting a range to numbers - i.e. any text to zero:
N(+A1:C3)
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.
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?
In some of those examples, e.g. for WORKDAY
and QUOTIENT
, the +
is converting a range to an array
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))
where A1:A3 contain dates
....it will return an error
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屋!