View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default adding numbers with letters

On Wed, 9 Jan 2008 07:16:59 -0800 (PST), wrote:

Thanx, you guys are great! Worked fine after tweaking security
settings.

One last question, sometimes the addends are fractions such as:

88 1/2grn+3wht+88 1/2grn

How do you tweak the code to see these?


Here's a bit shorter routine that should do that:

==============================================
Option Explicit
Function SumNums(str As String) As Double
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.Global = True
re.Pattern = "[A-Za-z]"
SumNums = Evaluate(re.Replace(str, ""))
End Function
==============================================
--ron