+ Reply to Thread
Results 1 to 17 of 17

SUM values only if cell starts with specific character

  1. #1
    Registered User
    Join Date
    08-25-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2010
    Posts
    6

    SUM values only if cell starts with specific character

    Hi guys,
    I'm a little upset about one "simply" function. I have data in one row. In every cell is value(number) but it begins with a letter(character). I need to sum VALUE ot these cells based on the character. Could anyone help me with this one? sum.jpg

  2. #2
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: SUM values only if cell starts with specific character

    In you pic, the sums are switched, right? the sum of the C's is 10 and the sum of D's is 13. Or do I misunderstand what you want?
    When I say semicolon, u say comma!

  3. #3
    Registered User
    Join Date
    08-25-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: SUM values only if cell starts with specific character

    Yup the sums are swapped, sorry for that. Anyway do you have a clue?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: SUM values only if cell starts with specific character

    Hi,

    As an array formula entered with Ctrl Shift Enter

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: SUM values only if cell starts with specific character

    Are your actual data rows also just 5 columns long? If so, I can write you a formula. If not, I think you need an array, which I know too little about.

  6. #6
    Registered User
    Join Date
    08-25-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: SUM values only if cell starts with specific character

    Well, I would like to use it for attendance record. So there will be used maximum 31 columns.

  7. #7
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: SUM values only if cell starts with specific character

    Haha there's your array

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    As an array formula entered with Ctrl Shift Enter

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    08-25-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: SUM values only if cell starts with specific character

    Thanks guys, It works perfectly!

  9. #9
    Forum Contributor
    Join Date
    08-02-2013
    Location
    Wageningen, The Netherlands
    MS-Off Ver
    365
    Posts
    495

    Re: SUM values only if cell starts with specific character

    Great! Please mark the thread as solved (above the first post) and reward Richard with a Reputation Point (lower left corner of his post).

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: SUM values only if cell starts with specific character

    Here's a non-array formula.

    A B C D E F
    1 Data D8 D4 C2 D1 C8
    2
    3 Totals C 10
    4 D 13

    This formula entered in C3 and copied down:

    =SUMPRODUCT((LEFT(B$1:F$1)=B3)*RIGHT(B$1:F$1))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  11. #11
    Registered User
    Join Date
    08-25-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: SUM values only if cell starts with specific character

    Hi, I have one more problem with two-digit numbers in the data cells.
    The result is counted correctly, but it displays only the last digit of the number. How can I set the result as a two-digit number?

    In the picture you can see that both results for character "C" are 6. But the corect result is 16. two-digit.png

  12. #12
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: SUM values only if cell starts with specific character

    Try this updated version of Tony's formula

    =SUMPRODUCT((LEFT(B$1:F$1)=B3)*RIGHT(B$1:F$1,LEN($B$1:$F$1)-1))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: SUM values only if cell starts with specific character

    Here's another one...

    Data Range
    A
    B
    C
    D
    E
    F
    1
    Data
    D8
    D40
    C2
    D1
    C18
    2
    3
    Totals
    C
    20
    4
    D
    49

    This formula entered in C3 and copied down:

    =SUMPRODUCT((LEFT(B$1:F$1)=B3)*MID(B$1:F$1,2,15))

  14. #14
    Registered User
    Join Date
    08-25-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: SUM values only if cell starts with specific character

    Thanks guys for your help,
    but now it works only with two-digit values and not with single ones / When I enter value for example "8", both formulas make an error: #VALUE!

    It is possible to make a formula that works both singledigit and two-digit numbers? singledigit.png
    Thank you so so much

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: SUM values only if cell starts with specific character

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    1
    Data
    D8
    D40
    8
    D1
    C18
    2
    3
    Totals
    C
    18
    4
    D
    49

    This array formula** entered in C3 and copied down:

    =SUM(IF(ISTEXT(B$1:F$1),IF(LEFT(B$1:F$1)=B3,--MID(B$1:F$1,2,15))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  16. #16
    Registered User
    Join Date
    08-25-2013
    Location
    Bratislava
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: SUM values only if cell starts with specific character

    Thank you Tony, now it works perfectly. You are awesome!

  17. #17
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: SUM values only if cell starts with specific character

    You're welcome. Thanks for the feedback!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 7
    Last Post: 05-17-2013, 08:02 AM
  2. Replies: 15
    Last Post: 03-27-2012, 08:48 AM
  3. Replies: 4
    Last Post: 09-06-2011, 10:36 AM
  4. Check if cell starts with certain character
    By ericc in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-10-2010, 04:47 PM
  5. Make a word bold if it starts with a particular character/string
    By lightsandsirens in forum Word Programming / VBA / Macros
    Replies: 9
    Last Post: 03-08-2010, 09:28 AM

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