简体   繁体   English

Excel 公式检查文本第 2 部分

[英]Excel formula to check for text part 2

Adding on to a question I asked yesterday, I am getting a "There's a problem with this formula" error in Excel.除了我昨天提出的问题之外,我在 Excel 中收到“此公式有问题”错误。

I am using the following formula:我正在使用以下公式:

=IF(OR(AD9834="In progress",BB9834="",ROUND(BW1-AI9834,0),IF(AD9834="Reopened",ROUND(BW1-AP9834,0),(BW1-AI9834,0))))

I just need a second set of eyes because I am not seeing where the error is located.我只需要第二双眼睛,因为我看不到错误所在的位置。

Solution is quick and I cover this in first few lines that follow.解决方案很快,我在接下来的前几行中介绍了这一点。 Have also expanded by highlighting a few tips/tricks I use to audit my own (and my teams'/others' excel workbooks/models etc.).还通过突出显示我用来审核自己(以及我的团队/其他人的 excel 工作簿/模型等)的一些提示/技巧进行了扩展。 Trust in order (flag any Qs you may have in this regard as req.)..按顺序信任(将您在这方面可能拥有的任何 Q 标记为 req。)..

Ta,塔,

Summary of changes变更摘要

  1. Include bracket to close OR statement in first / outer IF statement在第一个/外部 IF 语句中包含括号以关闭 OR 语句
  2. Include 'Round' in final part of function在 function 的最后部分包含“圆形”

Corrected Function:更正了 Function:

=IF(OR(AD9834="In progress",BB9834=""),ROUND(BW1-AI9834,0),IF(AD9834="Reopened",ROUND(BW1-AP9834,0),ROUND(BW1-AI9834,0)))

Auditing tips/identification routine审计提示/识别例程

When auditing / validating a function (especially long ones like this), I like to:在审核/验证 function (尤其是像这样长的)时,我喜欢:

(a) Use function assistant popup window (a) 使用 function 辅助弹窗 window

  • Click on each of the components of the function that appear in the little popup window when you enter the function输入 function 时,单击出现在小弹出 window 中的 function 的每个组件
  • This will highlight the corresponding part of the code in the function window.这将突出显示 function window 中代码的相应部分。

I'm talking about this popup in your case:在您的情况下,我正在谈论此弹出窗口: 在此处输入图像描述

You can drag it around the window, eg here I've placed at the bottom of the function window / toolbar:您可以将它拖到 window 周围,例如,这里我放置在 function window / 工具栏的底部:

功能窗口/对话工具栏底部的弹出助手

For instance, in screenshot below, I've clicked on 'logical test' part of the IF statement, and could immediately see where you've gone wrong - as the "logical test" component of the IF statement corresponded to your entire equation - ie you've obviously missed a comma or bracket somewhere to separate out 'value if True' and 'value if False' components:例如,在下面的屏幕截图中,我单击了 IF 语句的“逻辑测试”部分,并且可以立即看到您出错的地方 - 因为 IF 语句的“逻辑测试”部分对应于您的整个方程式 -即,您显然在某处遗漏了逗号或括号来分隔“如果为真则值”和“如果为假则值”组件:

逻辑测试组件

(b) Simplify by creating 'test' function (b) 通过创建“测试”function 来简化

Inserting the first bracket, and simplifying for the moment by referencing cells A1, B1 instead of A100095, B214032 etc., I repeat the 'click component' routine for the next sub-function (your OR statement).插入第一个括号,并暂时通过引用单元格 A1、B1 而不是 A100095、B214032 等来简化,我为下一个子功能(您的 OR 语句)重复“单击组件”例程。

(c) Evaluate sub-functions within function: (c) 评估 function 内的子功能:

I also like to highlight the various 'sub-functions' and evaluate them (press f9 - but be careful not to press 'enter' as it will embed/overwrite test function, instead press ctrl+Z to reverse the evaluation) within the function window/toolbar to see which ones are working/broken.我还想在 function 中突出显示各种“子功能”并评估它们(按 f9 - 但注意不要按“输入”,因为它会嵌入/覆盖测试 function,而不是按 ctrl+Z 来反转评估)窗口/工具栏以查看哪些正在工作/损坏。

Doing so simplifies checking the long function you have to something that looks like this:这样做可以简化检查长 function 你必须看起来像这样的东西:

审核时简化

ie step 1: highlight sub-function like the OR statement: *第1步:突出显示OR语句之类的子功能: *

步骤1

step 2: press F9 to temporarily evaluate:步骤 2:按 F9 临时评估:

步骤 2:f9:临时评估

step 3: repeat for each 'sub-function'第 3 步:对每个“子功能”重复

As I've fixed this item, no errors upon evaluation, I move onto next sub-function and eventually end up with an error when trying to evaluate your final if statement:由于我已经修复了这个项目,评估时没有错误,我进入下一个子功能,最终在尝试评估您的最终 if 语句时出现错误:

第 3 步:

step 4: repeat above for each sub-function of 'parent' sub-function第 4 步:对“父”子功能的每个子功能重复上述步骤

  • In this case, your 2nd IF statement, comprising 'children' = logical test, true / false sections of IF statement)... step 4: cancel out by pressing escape在这种情况下,您的第二个 IF 语句,包括 'children' = 逻辑测试,IF 语句的真/假部分)...第 4 步:按转义键取消

Doing so quickly allows me to identify your missing 'round' statement (I imagine it's this you intended to have) right at the end of the function.这样做可以让我在 function 的末尾识别出你缺少的“圆形”声明(我想这是你想要的)。

(d) Check brackets Penultimate step is to check opening and closing brackets - to ensure you have applied these correctly. (d) 检查括号倒数第二步是检查开始和结束括号 - 以确保您正确应用了这些。 Don't go with Excel's auto-fix proposal that sometimes pops up:不要 go 使用 Excel 有时会弹出的自动修复建议:

自动修复弹出窗口:永远不要接受这个!☺

(e) Apply changes to original function as required (e) 根据需要对原 function 进行更改

Finally, I manually adjust the original function according to the errors identified using the 'cut-down' temporary 'test function' created above.最后,我根据使用上面创建的 'cut-down' 临时 'test function' 识别的错误手动调整原始 function。

This leads to the following proposal for you to conveniently 'copy and paste' in the relevant / applicable cell:这导致以下建议,您可以方便地在相关/适用的单元格中“复制和粘贴”:

(see up top).. (见上)..

Ciao,再见,

J Ĵ

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

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