Excel从文本字符串中提取数字并求和

时间:2017-08-26 18:50:20

标签: excel excel-formula

我需要帮助。我有这个:

A1:6-2,6-2

A2:8-1,4-3

A3:6-2,6-3,5-3

我想在“ - ”之前总结所有数字。

示例:在B1中我希望从A1获得12(6 + 6)。

1 个答案:

答案 0 :(得分:0)

这个公式可以做到:

=SUMPRODUCT(--LEFT(TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",999)),(ROW(INDIRECT("1:" & LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1))-1)*999+1,999)),FIND("-",TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",999)),(ROW(INDIRECT("1:" & LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1)&"-")-1)*999+1,999)))-1))

enter image description here