оставить только числа в соседнюю ячейку, но так чтобы они суммировались
UDF
Код
Function iSumma(cell As String) As Double
Dim mo As Object
Dim n As Integer
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.MultiLine = True
.Pattern = "\d+,?\d+"
If .test(cell) Then
Set mo = .Execute(cell)
For n = 0 To mo.Count - 1
iSumma = iSumma + mo(n)
Next
End If
End With
End Function
если пустая ячейка показывает 0 как добавить в код строку, чтобы было пусто
Исходный текст в столбце А, суммирование в столбце В
Код
Sub iSumma_()
Dim mo As Object
Dim n As Integer
Dim i As Long
Dim iLastRow As Long
Dim temp As Double
iLastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("B1:B" & iLastRow).ClearContents
With CreateObject("VBScript.RegExp")
.Global = True
.IgnoreCase = True
.MultiLine = True
.Pattern = "\d+,?\d+"
For i = 1 To iLastRow
If .test(Cells(i, 1)) Then
Set mo = .Execute(Cells(i, 1))
Cells(i, 2).NumberFormat = "#,##0.00"
For n = 0 To mo.Count - 1
temp = temp + mo(n)
Next
Cells(i, 2) = temp
Else
Cells(i, 2).NumberFormat = "@"
Cells(i, 2) = ""
End If
temp = 0
Next
End With
End Sub
вариант к #4 чуть короче в столбце D данные в столбце C
Код
Function bbb#(t$)
Dim i&
With CreateObject("VBScript.RegExp"): .Pattern = "\d+,?(?:\d+)?": .Global = True
For i = 0 To .Execute(t).Count - 1: bbb = bbb + .Execute(t)(i): Next
End With
End Function