SOLVED

为什么这么写if函数会出错

%3CLINGO-SUB%20id%3D%22lingo-sub-1922634%22%20slang%3D%22zh-CN%22%3EWhy%20write%20an%20if%20function%20like%20this%20goes%20wrong%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1922634%22%20slang%3D%22zh-CN%22%3E%3CP%3EWhy%20is%20there%20500%20in%20the%20if%20function%20I%20entered%20in%20cell%20B2%3F%26lt%3B%3D%E6%97%B6%E4%BC%9A%E5%87%BA%E9%94%99%EF%BC%8C%E8%80%8C%E6%88%91%E5%9C%A8B3%E5%8D%95%E5%85%83%E6%A0%BC%E6%B2%A1%E6%9C%89%E8%BE%93%E5%85%A5500%26lt%3B%3D%2C%E5%B0%B1%E6%B2%A1%E6%9C%89%E9%97%AE%E9%A2%98%EF%BC%9F%E6%88%91%E7%9F%A5%E9%81%93%E8%BF%99%E4%B8%AA%E7%9A%84%E8%BE%93%E5%85%A5%E6%98%AF%E5%A4%9A%E4%BD%99%E7%9A%84%EF%BC%8C%E4%BD%86%E6%98%AF%E4%B8%BA%E4%BB%80%E4%B9%88%E5%87%BA%E9%94%99%E5%91%A2%EF%BC%9F%E4%BB%96%E6%98%AF%E6%80%8E%E4%B9%88%E5%88%A4%E6%96%AD%E7%9A%84%E5%91%A2%EF%BC%9F%3C%2FP%3E%3CP%3EThank%20you!%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%221.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F235524i2E9512E1F6715177%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%221.png%22%20alt%3D%221.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F235525iB5058D3A5AADBB31%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222.png%22%20alt%3D%222.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1922634%22%20slang%3D%22zh-CN%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1922860%22%20slang%3D%22de-DE%22%3ESubject%3A%20%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%99%E4%B9%88%E5%86%99if%E5%87%BD%E6%95%B0%E4%BC%9A%E9%94%99%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1922860%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F878417%22%20target%3D%22_blank%22%3E%40lyt77-_%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E4%BF%A1%E6%81%AF%3A%E7%94%A8%E6%88%B7%E4%B8%8D%E4%BC%9A%E8%AF%B4%E4%B8%AD%E6%96%87(%E6%96%87%E6%9C%AC%E6%98%AF%E4%BD%BF%E7%94%A8%E7%BF%BB%E8%AF%91%E8%BD%AF%E4%BB%B6%E5%88%9B%E5%BB%BA%E7%9A%84)%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E7%BB%8F%E6%82%A8%E7%9A%84%E8%AE%B8%E5%8F%AF%2C%E6%9C%80%E5%A5%BD%E9%99%84%E4%B8%8A%E4%B8%80%E4%B8%AA%E6%96%87%E4%BB%B6(%E4%B8%8D%E5%8C%85%E5%90%AB%E6%95%8F%E6%84%9F%E6%95%B0%E6%8D%AE)%E5%B9%B6%E6%8F%8F%E8%BF%B0%E6%82%A8%E7%9A%84%E9%97%AE%E9%A2%98%E3%80%82%20%3CBR%20%2F%3E%E8%BF%99%E6%A0%B7%E5%B0%B1%E5%8F%AF%E4%BB%A5%E6%9F%A5%E7%9C%8B%E5%AE%83%E6%98%AF-%E4%BB%B6%E8%BF%98%E6%98%AF-%E7%A0%81%20%3CBR%20%2F%3E%E5%AF%B9%E4%BA%8EExcel%E7%85%A7%E7%89%87%2C%E6%8F%92%E5%85%A5-%E6%97%A0%E6%B5%8E%E4%BA%8E%E4%BA%8B%2C%E5%9B%A0%E4%B8%BA%E9%94%99%E8%AF%AF%E5%8F%AF%E8%83%BD%E6%9D%A5-%E6%A0%B7%20%E7%A7%8D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E7%90%86%E8%A7%A3%E5%92%8C%E8%80%90%E5%BF%83%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%E5%88%A9%E8%AF%BA%20%E6%88%91%E6%A0%BC%E6%8B%89%20%E6%88%91%E4%BB%80%E4%B9%88%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3CBR%20%2F%3E%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1923192%22%20slang%3D%22zh-CN%22%3EBetreff%3A%20Why%20writing%20an%20if%20function%20like%20this%20goes%20wrong%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1923192%22%20slang%3D%22zh-CN%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F722750%22%20target%3D%22_blank%22%3E%40Nikolino%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20this%20formula%20to%20judge%20twice%2C%20first%3A%20whether%20it%20is%20less%20than%20500.%20Second%2C%20whether%20it%20is%20between%20500%20and%202000.%20At%20the%20second%20judgment%2C%20there%20was%20no%20%22500.%22%26lt%3B%3D%22%E7%9A%84%E7%BB%93%E6%9E%9C%E5%B0%B1%E4%B8%8D%E4%B8%80%E6%A0%B7%E4%BA%86%3C%2FP%3E%3CP%3EWhy%20is%20the%20result%20of%20cell%20B2%20different%20from%20that%20of%20cell%20C2%3F%3C%2FP%3E%3CP%3EHard!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1923366%22%20slang%3D%22de-DE%22%3ESubject%3A%20%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%99%E4%B9%88%E5%86%99if%E5%87%BD%E6%95%B0%E4%BC%9A%E9%94%99%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1923366%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F878417%22%20target%3D%22_blank%22%3E%40lyt77-_%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%E4%B8%8D%E5%B9%B8%E7%9A%84%E6%98%AF%2C%E6%88%91%E6%97%A0%E6%B3%95%E6%89%93%E5%BC%80%E6%82%A8%E7%9A%84%E6%96%87%E4%BB%B6%2C%E6%A0%87%E9%A2%98%E6%98%AF%E4%B8%AD%E6%96%87%2C%E5%B9%B6%E4%B8%94%E4%B8%8D%E5%85%81%E8%AE%B8%E5%9C%A8%E6%88%91%E7%9A%84%E5%B7%A5%E4%BD%9C%E7%AB%99%E4%B8%8A%E6%89%93%E5%BC%80%E3%80%82%20%3CBR%20%2F%3E%E5%A6%82%E6%9E%9C%E6%97%B6%E9%97%B4%2C%E6%88%91%E4%BC%9A%E6%82%A8%E4%BB%8A%E6%99%9A%E5%8E%BB%3C%2FP%3E%3CP%3E%E5%A6%82%E6%9E%9C%E6%88%91%E4%B9%9F-%E5%86%99%E6%82%A8%20%E8%AE%AE%E6%82%A8%E7%94%A8%E8%8B%B1-%E8%AF%B7%E6%B1%82%20(%E5%A6%82%E6%9E%9C%E6%82%A8%E4%BC%9A%E8%AF%B4%E8%8B%B1%2C%E8%AF%B7%E4%BD%BF%E7%94%A8Google%E7%BF%BB%E8%AF%91%2C%E8%BF%99%E6%A0%B7%E6%82%A8%E8%82%AF%E4%BB%85%E4%BB%85%E6%98%AF%E6%88%91%E4%BC%9A%E5%BE%97%E5%88%B0-%E5%86%B3%E6%A1%88%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E-%E5%85%B3----%E8%80%8C%E6%8F%90%E4%BE%9B%E5%B8%AE%E5%BE%97%E5%88%B0%E5%B8%AE%20%E4%B8%BA%E5%BF%B5%E8%80%8C%E6%8F%90%E4%BE%9B%E5%B8%AE%E7%BA%AF%E6%B4%81%E6%84%8F%E4%BA%8E%E5%AF%B9%20%E6%88%91%20%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4%E6%84%BF%E5%8F%82%E5%8A%A0%E6%98%AF%20%E6%88%91%E8%BF%99%E4%B8%AA%E8%AE%BA%E5%9D%9B---------------------------------------------------------------------------------------------------------------------%3C%2FP%3E%3CP%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E8%80%90%E5%BF%83%E5%92%8C%E6%97%B6%E9%97%B4%2C%E5%B9%B6%E5%BE%88%E6%8A%B1%E6%AD%89%E6%97%A0%E6%B3%95%E4%B8%BA%E6%82%A8%E6%8F%90%E4%BE%9B%E5%BF%AB%E9%80%9F%E4%BF%AE%E5%A4%8D%E3%80%82%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%E5%88%A9%E8%AF%BA%20%E6%88%91%E6%A0%BC%E6%8B%89%20%E6%88%91%E4%BB%80%E4%B9%88%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20%3CBR%20%2F%3E%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%20.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1923641%22%20slang%3D%22zh-CN%22%3EBetreff%3A%20Why%20does%20writing%20the%20if%20function%20make%20an%20error%20like%20this%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1923641%22%20slang%3D%22zh-CN%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F722750%22%20target%3D%22_blank%22%3E%40Nikolino%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20this%20formula%20to%20judge%20twice%2C%20the%20first%20time%3A%20if%20it%20is%20less%20than%20500.%20The%20second%20time%2C%20if%20it%20is%20between%20500%20and%202000.%20In%20the%20second%20judgment%2C%20the%20result%20of%20if%20have%20%22500%26lt%3B%3D%22%20is%20different.Why%20is%20the%20result%20of%20cell%20B2%20different%20from%20the%20result%20of%20cell%20C2%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20input%201200%20into%20A2%20and%20A3%2C%20input%20s%20IF%20(A2%20%26lt%3B500%2C0%2CIF(500%20%26lt%3B%3DA2%20%26lt%3B2000%2CA2*0.1%2CA2*0.2))%20%3CFONT%3E%20into%20B2%2C%20and%20the%20result%20is%20240%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%3CFONT%3EI%20input%20s%20IF%20(A3%26lt%3B500%2C0%2CIF(A3%26lt%3B2000%2CA3*0.1%2CA3*0.2))%20%26nbsp%3B%20into%20B3%20and%20the%20result%20is%20120.%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20feel%20very%20sorry%2C%20I%20have%20to%20use%20Google%20Translate%2C%20the%20English%20translation%20may%20be%20a%20bit%20strange.%3C%2FP%3E%3CP%3EHank!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

为什么B2单元格里,我输入的if函数里有500<=时会出错,而我在B3单元格没有输入500<=,就没有问题?我知道这个的输入是多余的,但是为什么出错呢?他是怎么判断的呢?

谢谢!

1.png2.png

10 Replies

@lyt77-_ 

 

信息:用户不会说中文(文本是使用翻译软件创建的)。

 

经您的许可,最好附上一个文件(不包含敏感数据)并描述您的问题。
这样就可以查看它是文件还是公式/代码。
对于Excel,插入的照片通常无济于事,因为错误的来源可能多种多样。

 

感谢您的理解和耐心

 

尼基利诺
我知道我什么都不知道(苏格拉底)

@Nikolino 

我想让这个公式判断两次,第一次:是否小于500.第二次,是否在500和2000之间。在第二次判断的时候,有没有"500<="的结果就不一样了

请问为什么B2单元格的结果和C2单元格的结果不一样呢?

辛苦!

 

@lyt77-_ 

不幸的是,我无法打开您的文件,标题是中文,并且不允许在我的工作站上打开。
如果有时间,我会在今晚去通知您。

如果我也建议您用英语写您的请求(如果您不会说英语,请使用Google翻译),这样您肯定会得到不仅仅是我的解决方案。

 

有关信息:
在这个论坛中,我们都是自愿参加的,也就是说,我们出于对人的善意的纯洁信念而提供帮助,为了得到帮助而提供帮助。

感谢您的耐心和时间,并很抱歉无法为您提供快速修复。

 

尼基利诺
我知道我什么都不知道(苏格拉底)

@Nikolino 

I want this formula to judge twice, the first time: whether it is less than 500. The second time, whether it is between 500 and 2000. In the second judgment, the result of whether have "500<=" is different.Why is the result of cell B2 different from the result of cell C2?

 

I input 1200 into A2 and A3, input     =IF(A2<500,0,IF(500<=A2<2000,A2*0.1,A2*0.2))   into  B2,and the result is 240.

 I input      =IF(A3<500,0,IF(A3<2000,A3*0.1,A3*0.2))   into B3 and the result is 120.

 

I feel very sorry, I have to use Google Translate, the English translation may be a bit strange. 

Thanks!

best response confirmed by lyt77-_ (Occasional Contributor)
Solution

@lyt77-_  Condition in second IF always returns FALSE

500<=A2<2000  => TRUE<2000  => FALSE  (logical value, as any text, always more than any number in logical operations)

 

Alternative formula:

=A2*LOOKUP(A2,{0,500,2000},{0,0.1,0.2})
用英语写您的请求更快
我一到家并想回答您,您就已经有了答案……而且合适的人也给出了正确的答案。

我们不能做伟大的事情-只有小事情,而有爱心的事情。

感谢您的耐心和时间。

祝您白天/夜晚都健康,快乐和充满爱。

尼基利诺
我知道我什么都不知道(苏格拉底)

@Nikolino

 Thank you! you really help me a lot.

 Wish you good health and good luck!Good mood every day!

 

Thanks a lot! I understand.
Wish you no troubles in your life!

@lyt77-_ you are welcome and take care

@lyt77-_ 

我没有做任何大事,只是向您展示了方法。 感谢Baklan先生,您有一个解决方案,我们大家都在这里,这个社区的另一个快乐成员。

 

我不能做伟大的事情-只有小事情,但是有爱的人。

 

再见了!

 

尼基利诺

我知道我什么都不知道(苏格拉底)