I need to know if I can sum cells that contain numbers and text in a cell IE
2C + 4T. I want to ignor the text part of the cell data and sum the numbers.
Thanks
This UDF removes all characters except digits, decimal point, and the
mathematical operators +-/*^. It then evaluates the expression that remains.
This should work on most variations you might use. IT does assume that neither
the decimal point nor the mathematical operators appear in the text portion.
To enter it, <alt-F11> opens the VBEditor.
Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code below into the window that opens.
To use it, enter a formula =EvalNums(cell_ref) into some cell.
===================================
Option Explicit
Function EvalNums(str As String) As Double
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "[^0-9+*/^.-]"
EvalNums = Evaluate(re.Replace(str, ""))
End Function
=====================================
--ron