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

时间:2013-11-02 23:33:44

标签: excel

有人可以告诉我为什么第二个IF语句在下面的代码中不起作用吗?

我基本上需要做三件事;

  1. 如果D,E,F,G,H中有值,那么我希望它用“,”键入 “和”像这样;蓝莓,小红莓,黑电流, 草莓和gojiberries
  2. 如果只有D,E,F,G的值那么;蓝莓,小红莓,黑电流和草莓
  3. 如果只有D,E,F的值那么;蓝莓,小红莓和黑潮
  4. 我只能让两个声明工作......

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

    我的行看起来像这样: D =蓝莓E =小红莓F =黑电流G =草莓H = gojiberries

    请帮忙

    亚历

2 个答案:

答案 0 :(得分:3)

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

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

答案 1 :(得分:1)

尝试使用此版本

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