LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Sum values in string in a cell

On Fri, 8 May 2009 14:10:59 -0700 (PDT), Harlan Grove
wrote:

Ron Rosenfeld wrote...
...
Sum of NO:

=EVAL(MCONCAT(--REGEX.MID(A1,"(?<=NO\.)\s*[-+]?\b[0-9,]*\.?[0-9]+\b",
INTVECTOR(REGEX.COUNT(A1,"(?<=NO\.)\s*[-+]?\b[0-9,]*\.?[0-9]+\b",
FALSE),1),FALSE),"+"))


I had wanted to avoid regexps, but if you're going to use 'em, use 'em
efficiently. Either

=SUMPRODUCT(--REGEX.MID(x,"(?<=NO\. )\d+",INTVECTOR(REGEX.COUNT(x,"NO
\. "),1)))

or

=EVAL(REGEX.SUBSTITUTE(x&"NO. 0",".*?NO\. (\d+)","+[1]"))

Sum of $:

=EVAL(MCONCAT(--REGEX.MID(A1,"(?<=\$)[-+]?\b[0-9,]*\.?[0-9]+\b",
INTVECTOR(REGEX.COUNT(A1,"(?<=NO\.)\s*[-+]?\b[0-9,]*\.?[0-9]+\b",
FALSE),1),FALSE),"+"))


Either

=SUMPRODUCT(--REGEX.MID(x&":","(?<=\$)[0-9,.]+(?=:)",
INTVECTOR(REGEX.COUNT(x&":","\$[0-9,.]+:"),1)))

or

=EVAL(SUBSTITUTE(REGEX.SUBSTITUTE(x&":",".*?\$
([0-9,.]+):","+[1]"),",",""))


Much better. Thanks.
--ron


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine which values are = 0 & create string [email protected] Excel Discussion (Misc queries) 2 December 18th 08 04:07 PM
changing text values to a different string sparks Excel Worksheet Functions 4 July 16th 07 07:01 PM
Sum delimited values in text string if... J Excel Worksheet Functions 7 February 24th 07 06:10 PM
Returning a string of values in an IF statement Dave F Excel Discussion (Misc queries) 1 January 11th 07 01:33 AM
Extracting numeric values from string RJF Excel Worksheet Functions 3 January 5th 05 10:48 PM


All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"