简体   繁体   English

如何在复杂的 excel 公式中添加注释

[英]How to add comment inside complex excel formula

Is it possible to add a comment within the cell of an excel formula?是否可以在 excel 公式的单元格内添加注释? I have an exceedingly long expression inside a cell that could better understood if I can comment within it.我在一个单元格中有一个非常长的表达式,如果我可以在其中发表评论,可以更好地理解它。

Excel 2010 is my version. Excel 2010是我的版本。 Here is an example cell I'd like to notate:这是我要标注的示例单元格:

=MID(
A4,
((FIND("n   ",A4,FIND(G4,A4))+75)+LEN(H4)+78),
(FIND("n   ",A4,(FIND("n   ",A4,FIND(G4,A4))+75))) - ((FIND("n   ",A4,FIND(G4,A4))+78))
)

The N() function allows you add comments directly inside your cells on your formulas. N()函数允许您直接在公式的单元格中添加注释。 To use the function to add a comment, simply add a plus sign (+) to the end of your formula, and then enter some text in quotes inside the parentheses, passing that text to the N() function. 要使用该函数添加注释,只需在公式的末尾添加加号(+),然后在括号内的引号中输入一些文本,并将该文本传递给N()函数。

Example: =YourFormula+N("comment") 示例: =YourFormula+N("comment")

Or you can use "add comment" in the Comments section of the Review tab. 或者,您可以在“审阅”选项卡的“注释”部分中使用“添加注释”。 http://www.howtogeek.com/162231/add-comments-to-formulas-and-cells-in-excel-2013/ http://www.howtogeek.com/162231/add-comments-to-formulas-and-cells-in-excel-2013/

For the problem Tom Sharpe mentions in the Answer by Ben Rhys-Lewis, there is a solution.对于 Tom Sharpe 在 Ben Rhys-Lewis 的回答中提到的问题,有一个解决方案。 Well, being Excel, probably five or six, but:好吧,作为 Excel,可能有五六个,但是:

For text functions you wish to append a comment to, use something like this:对于您希望附加注释的文本函数,请使用以下内容:

=CONCATENATE(IFERROR(A1/A2,""),T(N("comment")))

N() will return a "0" which T() will then make into an Excel blank. N() 将返回一个“0”,然后 T() 将使其成为 Excel 空白。 It acts like "" in a formula in that it adds nothing to or into a string though it will not be a null if you paste values with it... an Excel "blank" is born.它的作用类似于公式中的“”,因为它不会向字符串添加任何内容,但如果将值粘贴到它,它就不会是空值……Excel“空白”就诞生了。

Note that it works with the math if the division does not result in an error because while Excel makes text out fo the result, in the cell, it uses it as a number for math done on that cell's text-number result (for instance, a text "3.5" will still add to a numerical 9.5 in another cell tha that adds 6 to the "3.5" in the cell).请注意,如果除法不会导致错误,则它适用于数学,因为虽然 Excel 为结果生成文本,但在单元格中,它会将其用作对该单元格的文本编号结果进行数学运算的数字(例如,文本“3.5”仍将添加到另一个单元格中的数字 9.5 tha 将 6 添加到单元格中的“3.5”)。

Also, to make the comments stand out, you can break the piece of your formula with Alt-Enter right before and right after that piece and its comment.此外,为了使评论脱颖而出,您可以在该部分及其评论之前和之后使用 Alt-Enter 打破您的公式部分。 Not like real commenting, but standing out more than some horrid muddle that it just increased stands out, enough worth doing and you can almost always add spaces before the comment as well:不像真正的评论,但比它刚刚增加的一些可怕的混乱更突出,足够值得做,你几乎总是可以在评论前添加空格:

=function stuff function stuff
CONCATENATE(IFERROR(A1/A2,""),    T(N("comment")))
and a bit more function stuff and more and more and so on...

The N() comment function does not have to be the last portion of the function. N() 注释函数不必是函数的最后一部分 So this is a workable solution:所以这是一个可行的解决方案:

=+C6+N("description of C6 variable") +C7+N("C7 info") +C8+N("C8 info") =+C6+N("C6 变量描述") +C7+N("C7 信息") +C8+N("C8 信息")

While not required, for improved readability I use params to indicate the comment refers to several elements.虽然不是必需的,但为了提高可读性,我使用 params 来指示注释引用了几个元素。 For this example the first comment just refers to "q13" cell while the next two comments refer to the calculation between the "(...)"对于此示例,第一条注释仅指代“q13”单元格,而接下来的两条注释指代“(...)”之间的计算

=+AA435 * q13+N(bonus multiplier) +(c435*$d$4/a435)+N("profit scaled by area") +(p24*$q$5 + w12*3)+N("blah...") =+AA435 * q13+N(奖金乘数)+(c435*$d$4/a435)+N(“按面积计算的利润”)+(p24*$q$5 + w12*3)+N(“等等.. .”)

I always prefer to break up long complex formulas into a single simple consolidation formula that adds together hidden columns of intermediate formulas.我总是喜欢将长而复杂的公式分解成一个简单的合并公式,将中间公式的隐藏列加在一起。

The LET function that was released in 2020 (available to Microsoft 365 subscribers) makes it possible to rewrite complex formulas in a more readable way by using variables. 2020 年发布LET function (适用于 Microsoft 365 订阅者)使使用变量以更易读的方式重写复杂公式成为可能。 As Jim Pearson points out in his answer , you can also include comments as variables that are not used in the formula.正如 Jim Pearson 在他的回答中指出的那样,您还可以将注释作为未在公式中使用的变量包含在内。

Here is one of many ways you could rewrite your formula with variable names that help understand the different parts of the formula:以下是您可以使用有助于理解公式不同部分的变量名称重写公式的多种方法之一:

=LET(\0, "Extract characters from text based on the contents of the other columns.",
     text, A4,
     find_string_G, FIND(G4, text),
     find_string_n, FIND("n   ", text, find_string_G),
     start_num, (find_string_n+75) + LEN(H4) + 78,
     num_chars, FIND("n   ", text, (find_string_n+75)) - (find_string_n+78),
MID(text, start_num, num_chars)
)

You could use the LET function like this:您可以像这样使用 LET 函数:

=LET(
comment, "my comment",
SUM(P4:P10))

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

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