所以我正在尝试计算分数,在一个Excel单元格中相互添加?
例如:= 8.86 + 12.45 + 12.24 ......等等它可以算作3吗? 请帮忙,并提前谢谢!
答案 0 :(得分:0)
您没有说出您拥有的Excel版本。如果您使用Excel 2013,则此公式计算加号的数量并添加1:
=LEN(FORMULATEXT(A1))-LEN(SUBSTITUTE(FORMULATEXT(A1),"+",""))+1
如果您有早期版本,则此用户定义函数可能适合您。它需要一个或多个单元格作为其参数。如果你不熟悉UDF,Chip Pearson有good info on them:
Public Function CountNums(rng As Excel.Range) As Long
Dim cell As Excel.Range
Dim NumCount As Long
For Each cell In rng
If InStr(cell.Formula, "+") > 0 Then
NumCount = NumCount + (Len(cell.Formula) - Len(Replace(cell.Formula, "+", ""))) + 1
End If
Next cell
CountNums = NumCount
End Function