显示为字符串的单元格中的和数

时间:2013-10-03 11:44:57

标签: excel excel-2007

示例:单元格中的字符串

1 1 1 1          (total should be 4)
0.5 0.5          (total should be 1)
0.125 0.125      (total should be 0.250)
0.125 0.0625 8 1 (total should be 9.1875)

1 个答案:

答案 0 :(得分:1)

首先使用“文本到列”将单个数字转换为单个单元格。然后在各个数字上使用= SUM()函数。

修改#1

如果您需要VBA解决方案,请考虑:

Public Function AddCell(s As String) As Variant
    ary = Split(Trim(s), " ")
    AddCell = 0
    For i = LBound(ary) To UBound(ary)
        AddCell = AddCell + ary(i)
    Next i
End Function