Excel 公式包含错误
我在这个Excel公式中有一个错误,我无法弄清楚:
=LEFT(B3,FIND(",",B3&",")-1)&","&RIGHT(B3,LEN(B3)-FIND("&",B3&"&")),RIGHT(B3,LEN(B3)-SEARCH("@",SUBSTITUTE(B3," ","@",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))&", "&SUBSTITUTE(RIGHT(B3,LEN(B3)-FIND("&",B3&"&")-1),RIGHT(B3,LEN(B3)-SEARCH("@",SUBSTITUTE(B3," ","@",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))),""))
它可能看起来像一个大公式,但它的目的是如果单元格中没有&符号,则返回一个空单元格,如果没有逗号但是& 符号存在,则返回该符号,例如:
KNUD J & MARIA L HOSTRUP
为:
HOSTRUP,MARIA L
否则,没有 & 符号,但有一个逗号,所以我们只返回:LEFT(A1,FIND("&",A1,1)-1)。
看起来很基本,但公式一直给我错误消息并且没有指出问题。
I have an error in this excel formula and I can't just figure it out:
=LEFT(B3,FIND(",",B3&",")-1)&","&RIGHT(B3,LEN(B3)-FIND("&",B3&"&")),RIGHT(B3,LEN(B3)-SEARCH("@",SUBSTITUTE(B3," ","@",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))&", "&SUBSTITUTE(RIGHT(B3,LEN(B3)-FIND("&",B3&"&")-1),RIGHT(B3,LEN(B3)-SEARCH("@",SUBSTITUTE(B3," ","@",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))),""))
It may seem like a big formula, but all it's intended to do is if no ampersand is in a cell, return an empty cell, if no comma but ampersand exists, then return this, for example:
KNUD J & MARIA L HOSTRUP
into this:
HOSTRUP,MARIA L
Otherwise, there is no ampersand but there is a comma so we just return: LEFT(A1,FIND("&",A1,1)-1).
Seems basic, but formula has been giving me error message and doesn't point to the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的错误在这里:
此时,逗号不适用于任何东西,因为正确的运算符具有匹配的括号
至于你想要什么?让我们将其分解为您实际要求的内容:
则将其转过来,例如:
我猜你是想写最后一个完整的词?让我们标记最后一个完整的单词:
以及&符号和最后一个单词之间的东西
然后计算它很容易
好吧,如果你想要的话,让我们把它放在 B8 中
(但我认为你实际上是指 B3 而不是 A1),
这样你就得到了它(B5 包含你正在寻找的信息)它需要几个单元格,但它更容易以这种方式进行调试。如果您想折叠它,也可以(但这样做需要更多代码,因为我们可以通过多次引用先前计算的单元格来减少重复)。
摘要:
当我输入“KNUD J & MARIA L HOSTRUP”时,我在 B5 中得到“HOSTRUP,MARIA”。
Your error is here:
At this point, the comma doesn't apply to anthing, because the right operator has matching parens
As far as what you want? Let's break that up into what you actually asked for:
then turn this, for example:
I'm presuming you mean to put the last whole word? Let's mark the last whole word:
And the stuff between the ampersand and the last word
Then calculating it is easy
Well, if you want that, let's just put that in B8
(But I think you actually mean B3 instead of A1)
And there you have it (B5 contains the information you're looking for) It took a few cells, but it's easier to debug this way. If you want to collapse it, you can (but doing so is more code, because we can reduce duplication by referencing a previously calculated cell on more than one occasion).
Summary:
When I put in "KNUD J & MARIA L HOSTRUP", I get "HOSTRUP,MARIA" in B5.