以逗号分隔的整数字符串

时间:2019-02-13 04:12:01

标签: google-sheets sum

在Google表格中-我需要对一组数字求和,其中初始单元格包含定界符和非数字:

3; 6; 1; 3; None; 1; 1

我首先替换所有空格和非数字:

=REGEXREPLACE(AG24,"\D+",",")

给出:3,6,1,3,1,1

由于=SUM(3,6,1,3,1,1)正确地提供了15,所以我想尝试将REGEXREPLACE的结果传递到SUM()并神奇地进行计算,但是这样做的结果是0:

=SUM(REGEXREPLACE(AG24,"\D+",",")) = 0

我有点期待...

我也尝试过SUMPRODUCT,它也会产生0:

=SUMPRODUCT(ARRAYFORMULA(REGEXREPLACE(AG24,"\D+",","))) = 0

问题:那么我该如何求和字符串整数列表?

3 个答案:

答案 0 :(得分:1)

您可以尝试使用下面的公式,该公式将字符串直接转换为数组广告,然后对其求和。

=Sum(SPLIT(AG24,";"))

希望有帮助!

答案 1 :(得分:0)

请尝试:

=sum(split(REGEXREPLACE(AG24,"\D+",","),","))

答案 2 :(得分:0)

  • =SUMPRODUCT(SPLIT(AG24, ";"))

  • =SUMPRODUCT(SPLIT(REGEXREPLACE(AG24,"\D+"," ")," "))

也可以使用...