=SUM(--TEXTSPLIT(A1,"】",,TRUE))
=EVALUATE(SUBSTITUTE(A1,"】","+")&0)
Function SumText(inputText As String) As Double ' 功能:计算用"】"分隔的数字字符串的总和 Dim numbers() As String Dim i As Long Dim total As Double Dim cleanText As String ' 处理空输入 If inputText = "" Then SumDelimitedNumbers = 0 Exit Function End If ' 移除末尾多余的分隔符(如果存在) cleanText = inputText If Right(cleanText, 1) = "】" Then cleanText = Left(cleanText, Len(cleanText) - 1) End If ' 用"】"分割字符串 numbers = Split(cleanText, "】") ' 初始化总和 total = 0 ' 遍历所有分割后的元素 For i = LBound(numbers) To UBound(numbers) If numbers(i) <> "" Then ' 跳过空元素 ' 尝试转换为数字并累加 If IsNumeric(numbers(i)) Then total = total + CDbl(numbers(i)) Else total = total + 0 End If End If Next i ' 返回计算结果 SumText = totalEnd Function
好了,今天内容就是这么多,下次咱再接着说。温暖自己也给人力量,下次见~