+ Reply to Thread
Results 1 to 11 of 11

Summing numeric parts of alphanumeric values

  1. #1
    Registered User
    Join Date
    10-06-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    23

    Summing numeric parts of alphanumeric values

    Hi,

    I am wondering if you can sum the numeric parts of a range of cells containing alphanumeric values. Here is an example:

    values to sum: 500, a20, ab30
    expected results: 500 + 20 + 30 = 550.

    In this project, the number of values to sum is large and I do not wish to use long formulas to extract the numeric part of each cell within the range. I am also forbidden to use up extra cells as an intermediate working out. Can you help?

    Cheers guys.
    Last edited by amdk8800; 11-10-2009 at 10:07 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    re: Summing numeric parts of alphanumeric values

    Forbidden? By whom?

    I would use VBA to construct a User Defined Function especially to accomplish this. Is VBA forbidden, too?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723

    re: Summing numeric parts of alphanumeric values

    Is the numeric part always at the end as per your example?

    How many letters might there be, 1 2 .....or more?

    Are there many different letters or only a few?

  4. #4
    Registered User
    Join Date
    10-06-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Summing numeric parts of alphanumeric values

    Hi JBeaucaire,

    I said forbidden because my workbook is referenced to by other files and I don't want to screw up the existing format. I have considered using VBA too but I am not proficient enough to make it update the sum whenever the data in the range changes. Plus I want this to happen to several worksheets within this workbook, the scripting can be quite nasty.

  5. #5
    Registered User
    Join Date
    10-06-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Summing numeric parts of alphanumeric values

    Hi Daddylonglegs,

    I am happy if you can solve this for the case where the values within the range is either numeric or take the form "a"+number (eg. 30, a50, a80).

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723

    Re: Summing numeric parts of alphanumeric values

    If the letter is always "A" then you could use this formula

    =SUMPRODUCT(SUBSTITUTE(0&UPPER(A1:A100),"A","")+0)

    or for any letters but only either a single one at the start or none at all

    =SUMPRODUCT((0&MID(A1:A100,1+ISERR(LEFT(A1:A100)+0),10))+0)

    Where data is in the range A1:A100

    both formulas will also allow blanks in the range

  7. #7
    Registered User
    Join Date
    10-06-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Summing numeric parts of alphanumeric values

    Hi Daddylonglegs,

    Thanks for your prompt assistance. Your formula works well. But I am stumped when trying to incorporate this with a SUMIF function. I mean my range is a row under different column headings. I wish to sum those cells with column heading begining with "Actual". Normally without the alphanumeric issue, I would use something like:

    =SUMIF($A$1:$AB$1, "Actual*",A2:AB2)

    Any suggestion?

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723

    Re: Summing numeric parts of alphanumeric values

    You can do that within SUMPRODUCT, so for the first formula I posted try

    =SUMPRODUCT(SUBSTITUTE(0&UPPER(A2:AB2),"A","")*(LEFT(A1:AB1,6)="Actual"))

  9. #9
    Registered User
    Join Date
    10-06-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Summing numeric parts of alphanumeric values

    Hi Daddylonglegs, This works perfectly. You are a legend. Thanks for the trick.

  10. #10
    Registered User
    Join Date
    11-17-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Summing numeric parts of alphanumeric values

    I can use the below if my cells are either blank or contain a text string with an "a". Is there a way to adjust this so that the numeric portions of only the cells with an a in them get summed.

    If I use the below and my range contains any letter other than a I get an error i would like cells with other letters to be somehow ignored

    IE my column may contain 8a, 4a and the summing works great but if my column contains 8a, 4a, m I get an error




    Quote Originally Posted by daddylonglegs View Post
    If the letter is always "A" then you could use this formula

    =SUMPRODUCT(SUBSTITUTE(0&UPPER(A1:A100),"A","")+0)

    or for any letters but only either a single one at the start or none at all

    =SUMPRODUCT((0&MID(A1:A100,1+ISERR(LEFT(A1:A100)+0),10))+0)

    Where data is in the range A1:A100

    both formulas will also allow blanks in the range

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723

    Re: Summing numeric parts of alphanumeric values

    Hello aclx2s,

    Please can you start a new thread with your question. If you think this thread is relevant then please quote the formulas and/or link back to this thread, thanks

+ 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