我尝试在Excel中使用公式,以便:
(a)比较D
和R
两列中的所有值;
(b)确定哪些值包含在R
中,而不包含在D
中;
(c)条件是对于D
单元格中的每个值;列A
的同一行中存在等于单元格DRM!$W$1
的值
(d)忽略所有这些列的行1:5
中的值;(e)从单元格AR6
开始,列出R
中包含但D
中不包含的所有数值
下面是我使用的公式:
=IF(ISERROR(INDEX($R$6:$R$1000,SMALL(IF(ISERROR(MATCH($R$6:$R$1000,$D$6:$D$1000,0))),IF($A$6:$A$1000=DRM!$W$1,ROW($R$6:$R$1000)-ROW($R$6)+1)),ROW()-ROW($AS$5)))),"Not found",INDEX($R$6:$R$1000,SMALL(IF(ISERROR(MATCH($R$6:$R$1000,$D$6:$D$1000,0))),IF($A$6:$A$1000=DRM!$W$1,ROW($R$6:$R$1000)-ROW($R$6)+1)),ROW()-ROW($AS$5))))
当在列D中有匹配项时,该公式工作正常,但是当没有匹配项时,它返回0而不是预期的文本“Not found”。有人能解释一下为什么会发生这种情况吗?
在D列和R列上有不同的值,但是它们没有被分类为“IRRBB”,所以答案应该是“未找到”。
我试着把这个公式作为矩阵(Ctrl + Shift + Enter
)和标准公式使用,有趣的是,当我把这个公式作为矩阵用于Z列和K列而不是R列时,我得到了正确的答案。
我怎样才能去掉答案0
而得到答案Not found
?
我正在使用微软® Excel®微软365 MSO(版本2212构建16.0.15928.20278)64位在Windows 10上.
这些是列和单元格中的所有值:
x一个一个一个一个x一个一个二个x
提前感谢您所能提供的任何帮助!
1条答案
按热度按时间b1zrtrql1#
I think you may have a parenthesis in the wrong place in your formula. I pasted your formula into Notepad++ counted 22x
(
but 24x)
. That's no good. That almost always means you are closing off some nested part of the formula sooner than you think you are.I believe the following two
highlighted
parenthesis are placed in the wrong place:=IF(ISERROR(INDEX($R$6:$R$1000,SMALL(IF(ISERROR(MATCH($R$6:$R$1000,$D$6:$D$1000,0))),IF($A$6:$A$1000=DRM!$W$1,ROW($R$6:$R$1000)-ROW($R$6)+1)),ROW()-ROW($AS$5)))
)
,"Not found",INDEX($R$6:$R$1000,SMALL(IF(ISERROR(MATCH($R$6:$R$1000,$D$6:$D$1000,0))),IF($A$6:$A$1000=DRM!$W$1,ROW($R$6:$R$1000)-ROW($R$6)+1)),ROW()-ROW($AS$5))))
That first superfluous
)
closes off the completion of the IF() statement so you never make it to the "what if FALSE?" result of the IF.Here's how I solve/prevent that...
I use the LET() function to help me simplify really complex formulas, and once you get used to it, it’s life-changing. Using LET(), combined with using
ALT-Returns
to create non-breaking carriage returns in the formula is a huge simplifier. LET allows you to separate the part of the function that gathers all the data, from the part that actually performs the logic.LET() is only available in O365/Excel 2021, but you have that, so we're good there.
Your formula, as best I can tell, becomes:
I may not have the descriptions worded quite right, but you can see how it just changes the complexion of the whole formula and simplifies debugging. It also cuts execution time in half because the big hairy INDEX function is only performed one instead of twice.
Using this annotation I can immediately and easily spot my premature
)
.Absent all the defintions, what you want the logic format of your formula to be is:
=LET( IF( ISERROR( fullMonty ) , "Not found" , fullMonty ) )