+ Reply to Thread
Results 1 to 9 of 9

Sum up the digits within a range of cells

  1. #1
    Registered User
    Join Date
    11-28-2008
    Location
    Hong Kong
    Posts
    2

    Sum up the digits within a range of cells

    I am looking for a formula to sum up all the digit(s) within a range of cells, e.g.

    Please Login or Register  to view this content.
    The formula will return 47 (8+2+1+1+5+8+3+9+1+4+1+4).

    I tried MID function but it is not working properly as the value within the cell could be either single digit or double digits.

    Many thanks in advance.
    Last edited by NBVC; 12-01-2008 at 11:07 AM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    =--left(a1)+if(mid(a1,2,1)="",0,--mid(a1,2,1))
    ah i notice they are not in a1,a2,a3......,bother
    back in a mo! no thats ok just drag across
    better still
    =IF(ISBLANK(a1),0,--LEFT(a1)+IF(MID(a1,2,1)="",0,--MID(a1,2,1)))
    Last edited by martindwilson; 11-28-2008 at 06:49 AM.

  3. #3
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    If they are only max 2 digit numbers then perhaps:

    =SUMPRODUCT(SUM(MID(TEXT($A$1:$H$1,"00"),{1;2},1)+0))

    Confirmed with Ctrl+Shift+Enter

    Richard
    Last edited by Richard Schollar; 11-28-2008 at 07:03 AM. Reason: needed a ; not a ,
    Richard Schollar
    Microsoft MVP - Excel

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Well, I can't figure out how to do it in a ROW like you suggested, but if the digits were in a column, this formula would do it:
    Please Login or Register  to view this content.
    This is an array formula, so you confirm it by pressing CTRL-SHIFT-ENTER, and your sample total should return 47. If you just press ENTER, it will return 3, which is wrong. Confirm the array for 47.

    Adjust your column range to fit, blank cells are ignored.
    _________________
    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!)

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Quote Originally Posted by RichardSchollar View Post
    =SUMPRODUCT(SUM(MID(TEXT($A$1:$H$1,"00"),{1;2},1)+0))
    Should be able to use

    =SUMPRODUCT(MID(A1:H1&"00",{1;2},1)+0)

    Is this total, 47 or whatever, your end result or are you doing further calculations?

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Sum up the digits within a range of cells

    Another suggestion
    Please Login or Register  to view this content.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  7. #7
    Registered User
    Join Date
    11-28-2008
    Location
    Hong Kong
    Posts
    2
    Quote Originally Posted by daddylonglegs View Post
    Should be able to use

    =SUMPRODUCT(MID(A1:H1&"00",{1;2},1)+0)

    Is this total, 47 or whatever, your end result or are you doing further calculations?
    Thanks all! Appreciate your help very much. Actually I will do further calculation.

    I am working on a check digit verification formula. Your solutions here solved a big part of the task. Many thanks again.

    I noticed some of the thread titles began with "[Solved]", is it one of the protocols here? That the thread starter should put "[Solved]" if they get the answer?

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by freemaniam View Post
    I noticed some of the thread titles began with "[Solved]", is it one of the protocols here? That the thread starter should put "[Solved]" if they get the answer?
    Yes.. that is the protocol

    Go to your first post in this thread and click Edit

    Click Go Advanced and select [Solved] from the Title dropdown

    Click Save Changes.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  9. #9
    Registered User
    Join Date
    01-14-2013
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    1

    Re: Sum up the digits within a range of cells

    I know this thread is years old, but I just want to say thank you so much for this. You've saved me literally days of manual counting. Thank you!

+ 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