简体   繁体   English

为什么这个公式不起作用?

[英]Why isn't this formula working?

Can somebody tell me why the second IF statement isn't working in the below code? 有人可以告诉我为什么第二个IF语句不能在下面的代码中工作吗?

I basically require 3 things to happen; 我基本上需要做三件事;

  1. If there is a value in D,E,F,G,H then i want it to type with "," "and" like this; 如果D,E,F,G,H中有一个值,那么我希望它用“,”,“和”这样输入; blueberries, cranberries, black currents, strawberries and gojiberries 蓝莓,小红莓,黑潮,草莓和gojiberries
  2. If there is a value in only D,E,F,G then; 如果只有D,E,F,G的值那么; blueberries, cranberries, black currents and strawberries 蓝莓,小红莓,黑电流和草莓
  3. If there is a value in only D,E,F then; 如果只有D,E,F的值那么; blueberries, cranberries and black currents 蓝莓,小红莓和黑电流

I can only get two of the statements to work... 我只能得到两个陈述......

=IF(H8=0,(D8)&", "&(E8)&", "&(F8)&" and "&(G8),(IF(G8=0,(D8)&", "&(E8)&" and "&(F8),(D8)&", "&(E8)&", "&(F8)&", "&(G8)&" and "&(H8)))) = IF(H8 = 0,(D8)&“,”&(E8)&“,”&(F8)&“和”&(G8),(IF(G8 = 0,(D8)&“,”& (E8)&“和”&(F8),(D8)&“,”&(E8)&“,”&(F8)&“,”&(G8)&“and”&(H8)))))

My rows looks like this: D=blueberries E=cranberries F=black currents G=strawberries H=gojiberries 我的行看起来像这样:D =蓝莓E =小红莓F =黑电流G =草莓H = gojiberries

Please help 请帮忙

Alex 亚历克斯

这将仅返回非空白的单元格值的串联,并在值之间使用逗号,除非下一个单元格为空,在这种情况下,逗号将替换为" and "

=D8&IF(E8<>"",IF(F8<>"",", "," and "),)&E8&IF(F8<>"",IF(G8<>"",", "," and "),)&F8&IF(G8<>"",IF(H8<>"",", "," and "),)&G8&IF(H8<>""," and "&H8,"")

尝试使用此版本

=D8&", "&E8&", "&F8&IF(G8=0,"",", "&G8)&IF(H8=0,"",", "&H8)

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

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