Попробуйте следующую пользовательскую функцию:
Public Function Zum(rng As Range) As Variant
Dim r As Range, s As String, L As Long, i As Long
Dim numbr As String, CH As String
Zum = 0
For Each r In rng
s = r.Text
If s <> "" Then
L = Len(s)
numbr = ""
For i = 1 To L
CH = Mid(s, i, 1)
If CH Like "[0-9]" Or CH = "." Then
numbr = numbr & CH
End If
Next i
If numbr <> "" Then
Zum = Zum + CDbl(numbr)
End If
End If
Next r
End Function
Например:
Это добавит ячейки, но удалитвсе, кроме цифр и десятичной точки из ячеек перед добавлением.
РЕДАКТИРОВАТЬ # 1:
Эта версия кода обрабатывает только вправобольшинство цифр каждой ячейки,
игнорирование алфавитов и десятичной точки:
Public Function Zum(rng As Range) As Variant
' version #2 only sum the right-most digits and ignore the decimal point
Dim r As Range, s As String, L As Long, i As Long
Dim numbr As String, CH As String
Zum = 0
For Each r In rng
s = r.Text
If s <> "" Then
L = Len(s)
numbr = ""
For i = L To 1 Step -1
CH = Mid(s, i, 1)
If CH Like "[0-9]" Then
numbr = CH & numbr
Else
Exit For
End If
Next i
If numbr <> "" Then
Zum = Zum + CDbl(numbr)
End If
End If
Next r
End Function
и, если вам нужна только одна самая правая цифра :
Public Function Zum(rng As Range) As Variant
' version #3 only sum the right-most digit and ignore the decimal point
Dim r As Range, s As String, L As Long, i As Long
Dim numbr As String, CH As String
Zum = 0
For Each r In rng
s = r.Text
If s <> "" Then
CH = Right(s, 1)
If CH Like "[0-9]" Then
Zum = Zum + CLng(CH)
End If
End If
Next r
End Function