简体   繁体   English

如何在excel列中添加逗号分隔的数字?

[英]how to add comma separated numbers in excel column?

How do I get the desired_output for a given input column containing comma-separated single numeric values as shown in the picture?如何获取包含以逗号分隔的单个数值的给定输入列的desired_output输出,如图所示?

Thanks for your help!谢谢你的帮助! 在此处输入图片说明

As you already solved this without VBA you could also use a User Defined Function由于您已经在没有 VBA 的情况下解决了这个问题,因此您也可以使用用户定义的函数

Function mySum(s As String, del As String)

Const Plus = "+"

    s = Replace(s, del, Plus)
    mySum = Evaluate(s)

End Function

You would use it like that你会像那样使用它

=mySum(A1,",")

A similar way is described here 这里描述类似的方式

Assuming you have your comma-separated values in cell A1, the following array formula will add all such values:假设您在单元格 A1 中有逗号分隔的值,以下数组公式将添加所有这些值:

=SUM((TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",255)),1+(ROW(A1:A999)-1)*255,255)) & "0")/10)

To properly return the formula, you need to press CONTROL+SHIFT+ENTER , instead of just the usual ENTER .要正确返回公式,您需要按CONTROL+SHIFT+ENTER ,而不仅仅是通常的ENTER

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

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