+ Reply to Thread
Results 1 to 15 of 15

Sum numbers left of a character from within a string

  1. #1
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Sum numbers left of a character from within a string

    Please see attached sheet. I can count the number of occurances that a Variable is found in a string but need a formula that will find that variable and sum up only the first set of numbers to the left.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Sum numbers left of a character from within a string

    look into attachnent array formula
    Attached Files Attached Files
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  3. #3
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Re: Sum numbers left of a character from within a string

    Tom, thanks for the quick response, its close but not quite there. With the formula in WHI the result should be 10.5 not 2.

  4. #4
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Re: Sum numbers left of a character from within a string

    Sorry, checking your formula I see I have misled slightly. I need a sum of the number to the left of that Letter not from the far left.

  5. #5
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Sum numbers left of a character from within a string

    Maybe upload new attachment with all expected results in every condition but in my opinion it will be rather hard to gain without VBA

  6. #6
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Re: Sum numbers left of a character from within a string

    Please find attached workbook with expected results

    Thanks
    Attached Files Attached Files

  7. #7
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Sum numbers left of a character from within a string

    Try this array formula

    =SUMPRODUCT((ISNUMBER(FIND(G3,$A$4:$E$4,1)))*(IFERROR(MID($A$4:$E$4,FIND(G3,$A$4:$E$4,1)-1,1),0)))
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  8. #8
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Re: Sum numbers left of a character from within a string

    Again it is close but not quite, the formula appears to be adding only the first number on the left ie. "1" and not the whole number ie. "10.5". I can see that the number of characters in the formula is set to 1 but I don't know how to make that a variable to suit all.

  9. #9
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Sum numbers left of a character from within a string

    is VBA an option for this? or do you want to stick to a formula?

  10. #10
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Re: Sum numbers left of a character from within a string

    VBA may be an option, I have a large number of cells I need the formula in but a pre-defined Function could work ok.

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480

    Re: Sum numbers left of a character from within a string

    From your 1st example
    ' I can use a different separator " . " if it helps
    With 4S.4H. you only want to use the 4
    But
    10.5WHI. you want to use the 10.5

    Using a comma as a seperator would help a lot.

  12. #12
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Sum numbers left of a character from within a string

    you could use this UDF, i changed the delimiter to ;

    put this code in a new module

    Please Login or Register  to view this content.
    in your sheet use this syntax

    =FindVarSum(G3,$A$4:$E$4)

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Sum numbers left of a character from within a string

    With comma separator try this formula in G4

    =COUNTIF($A$4:$E$4,"*"&G3&",*")

    then this "array formula" in H4

    =SUM(IFERROR(TRIM(RIGHT(SUBSTITUTE(LEFT($A4:$E4,FIND(G3&",",$A4:$E4)-1),",",REPT(" ",9)),9))+0,0))

    confirmed with CTRL+SHIFT+ENTER

    ....and then drag both of those across, see attached
    Audere est facere

  14. #14
    Forum Contributor
    Join Date
    01-24-2011
    Location
    Sheppey
    MS-Off Ver
    Excel 2010
    Posts
    239

    Re: Sum numbers left of a character from within a string

    Thank you very much, would not of got there without you. I will go with the Function option as this is a lot easier to input.

  15. #15
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Sum numbers left of a character from within a string

    or

    Please Login or Register  to view this content.
    in a cell

    PHP Code: 
    =freq_snb($A$4:$E$4;G3)

    =
    sum_snb($A$4:$E$4;G3



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1