简体   繁体   English

如果在谷歌表格中

[英]IF in google sheets

I'm referencing a cell in google sheets using =IF(SEARCH("United States",D14)>0,MID(D14,FIND(">",D14)+1,FIND("United States",D14)-FIND(">",D14)-3),MID(D14,FIND(">",D14)+1,FIND("Canada",D14)-FIND(">",D14)-3))我正在使用=IF(SEARCH("United States",D14)>0,MID(D14,FIND(">",D14)+1,FIND("United States",D14)-FIND(">",D14)-3),MID(D14,FIND(">",D14)+1,FIND("Canada",D14)-FIND(">",D14)-3))

D14 looks like this Philadelphia, United States D14看起来像这个Philadelphia, United States

So my IF statement correctly returns Philadelphia.所以我的 IF 语句正确返回了费城。 However, if I change it to a Canadian city, let's say Toronto, Canada , I receive this error: "In SEARCH evaluation, cannot find 'United States' within"但是,如果我将其更改为加拿大城市,例如Toronto, Canada我会收到此错误:“在 SEARCH 评估中,无法在其中找到‘美国’”

Am I using SEARCH incorrectly?我是否错误地使用了 SEARCH? Not sure没有把握

 =IF(SEARCH("United States",D14)>0,
 MID(D14,FIND(">",D14)+1,FIND("United States",D14)-FIND(">",D14)-3),
 MID(D14,FIND(">",D14)+1,FIND("Canada",D14)-FIND(">",D14)-3))

Not sure what you are trying to do, but when testing your formula on the given example, contrary to your claim it's not actually working.不确定您要做什么,但是在给定示例上测试您的公式时,与您的说法相反,它实际上不起作用。

In your FIND s you seem to be looking for > and not for comma which is your delimiter.在您的FIND您似乎正在寻找>而不是作为您的分隔符的逗号。 If you want to find whatever is after the comma, you can use a much simpler formula without any IF s如果你想找到逗号后的任何内容,你可以使用一个更简单的公式,没有任何IF s

 =right(D14,len(D14)- find(", ",D14)-1)

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

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