在Excel中汇总各列的单元格值

时间:2016-02-27 09:08:40

标签: excel excel-formula

screenshot of excel

我希望A栏显示:

  

概要
  黑色[3XL] * 1,黑色[4XL] * 1
  黑色[6XL] * 3
  黑色[2XL] * 1

我可以使用哪些公式?

4 个答案:

答案 0 :(得分:1)

您可以在A2中输入此公式:

=MID(IF(ISBLANK(B2), "", ", " & B$1 & "*" & B2) &
     IF(ISBLANK(C2), "", ", " & C$1 & "*" & C2) & 
     IF(ISBLANK(D2), "", ", " & D$1 & "*" & D2) & 
     IF(ISBLANK(E2), "", ", " & E$1 & "*" & E2) & 
     IF(ISBLANK(F2), "", ", " & F$1 & "*" & F2) & 
     IF(ISBLANK(G2), "", ", " & G$1 & "*" & G2) & 
     IF(ISBLANK(H2), "", ", " & H$1 & "*" & H2) & 
     IF(ISBLANK(I2), "", ", " & I$1 & "*" & I2),  3, 200) 

...然后向下复制该公式。

答案 1 :(得分:0)

我找到了解决方案。在A2中输入以下代码:

=IF(B2,B$1 & "*" & B2 & ", ", "") & IF(C2,C$1 & "*" & C2 & ", ", "") & IF(D2,D$1 & "*" & D2 & ", ", "")...

然后向下拖。

答案 2 :(得分:0)

如果允许VBA,另一种方法是使用现成的连接函数,如this one和数组公式: -

=StringConcat(",",IF(B2:I2="","",B$1:I$1&"*"&B2:I2))

必须使用 Ctrl Shift 输入

作为数组公式输入

enter image description here

答案 3 :(得分:0)

在A2中使用以下代码并向下复制。 = MID(CONCATENATE(IF(B2<>""""& B $ 1&" "& B2, ""),IF(C2&#>"",","& C $ 1&" &# 34;& C2,""),IF(D2"",","& D $ 1&" "& D2,""),IF(E2&#>"",","& E $ 1& ;" "& E2,""),IF(F2"","," ;&安培; F $ 1和;" "&安培; F2,"&#34),IF(G2<>""&#34 ;,"& G $ 1&" "& G2,""),IF(H2&#"&# 34;,","& H $ 1&" "& H2,""),IF(I2<>& #34;",","& I $ 1&" "& I2,"")), 3,1000)