如何计算Excel中一个单元格中相加的分数

时间:2022-08-03 22:18:13

So I'm trying to count fraction numbers, added to each other in one Excel cell?

所以我正在尝试计算分数,在一个Excel单元格中相互添加?

For instance: =8.86+12.45+12.24...etc so it can count it as 3? Please help, and Thank you in advance!

例如:= 8.86 + 12.45 + 12.24 ......等等它可以算作3?请帮忙,并提前谢谢!

1 个解决方案

#1


0  

You don't say what version of Excel you have. If you have Excel 2013, this formula counts the number of plus signs and adds 1:

您没有说出您拥有的Excel版本。如果您有Excel 2013,此公式计算加号的数量并添加1:

=LEN(FORMULATEXT(A1))-LEN(SUBSTITUTE(FORMULATEXT(A1),"+",""))+1

If you have an earlier version, this User Defined Function might work for you. It takes one or more cells as its argument. If you're not familiar with UDFs, Chip Pearson has good info on them:

如果您有早期版本,则此用户定义函数可能适合您。它需要一个或多个单元格作为其参数。如果你不熟悉UDF,Chip Pearson有很好的信息:

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

#1


0  

You don't say what version of Excel you have. If you have Excel 2013, this formula counts the number of plus signs and adds 1:

您没有说出您拥有的Excel版本。如果您有Excel 2013,此公式计算加号的数量并添加1:

=LEN(FORMULATEXT(A1))-LEN(SUBSTITUTE(FORMULATEXT(A1),"+",""))+1

If you have an earlier version, this User Defined Function might work for you. It takes one or more cells as its argument. If you're not familiar with UDFs, Chip Pearson has good info on them:

如果您有早期版本,则此用户定义函数可能适合您。它需要一个或多个单元格作为其参数。如果你不熟悉UDF,Chip Pearson有很好的信息:

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