+ Reply to Thread
Results 1 to 10 of 10

Formula help to sum numbers following text

  1. #1
    Registered User
    Join Date
    03-29-2012
    Location
    CA, USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Formula help to sum numbers following text

    Hello,

    I need a formula to sum numbers that follow text.

    For example, cells A1:A5 contain

    P8
    U1
    B4
    B12
    P7

    Sum in A6 should be 32

    Thanks in advance.

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Formula help to sum numbers following text

    Is it always only 1 letter?
    Sincerely
    S?ren Larsen

    "Give a man a fish, and you'll feed him for a day. Give a man a fishing rod, and he'll steal your yacht!"

  3. #3
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Formula help to sum numbers following text

    Hi Ex-cel, welcome to the forum. If your cells always contain one letter followed only by numbers, you could use the array function:

    =SUM(MID(A1:A5,2,LEN(A1:A5))+0)

    This must be confirmed using CTRL+SHIFT+ENTER, not just ENTER. When done properly, Excel will automatically add braces, {}, around your formula.

  4. #4
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Formula help to sum numbers following text

    Edit: Deleted
    Last edited by Søren Larsen; 03-29-2012 at 06:35 PM.

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Formula help to sum numbers following text

    Actually, Soren, using the +0 in my formula converts any number stored as a string (which the MID function creates anyway) to a true number and drops any additional spaces. So "P7__" would become 7 (underscores representing spaces).

  6. #6
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Formula help to sum numbers following text

    Quote Originally Posted by Paul View Post
    Actually, Soren, using the +0 in my formula converts any number stored as a string (which the MID function creates anyway) to a true number and drops any additional spaces. So "P7__" would become 7 (underscores representing spaces).
    Ok, but for some reason that doesn't work for me. Is that because the space is at the end?

    EDIT1: I guess not after rereading your reply.

    EDIT2: Alright, I was a little to fast there; I didn't have spaces after the strings, but rather some other formatting resembling a " ". Thanks Paul!
    Last edited by Søren Larsen; 03-29-2012 at 06:35 PM.

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

    Re: Formula help to sum numbers following text

    This would also do it for single letters

    =SUMPRODUCT(REPLACE(A1:A5,1,1,"")+0)
    Audere est facere

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: Formula help to sum numbers following text

    Thanks, DDL. Now of course I tested both with a blank cell in the range. Both error out, but I was able to slightly adjust DDL's to handle blanks in the range by changing the "" to 0.

    =SUMPRODUCT(REPLACE(A1:A5,1,1,0)+0)

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

    Re: Formula help to sum numbers following text

    Ah, yes, I didn't think of doing it that way, nice one

  10. #10
    Registered User
    Join Date
    03-29-2012
    Location
    CA, USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Formula help to sum numbers following text

    THANK YOU ALL!
    The following worked best since I did have some blank spaces as well.
    =SUMPRODUCT(REPLACE(A1:A5,1,1,0)+0)

    Really appreciate your help with this.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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