+ Reply to Thread
Results 1 to 6 of 6

sumif cell begins with a number but also contains letters

  1. #1
    Registered User
    Join Date
    07-20-2011
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    15

    sumif cell begins with a number but also contains letters

    In column A I have customer codes which can be all numbers or numbers and letters. For example, it can be 64223 or 523R3 or A382K. In column B I have invoice amounts. I need to be able to add up the amounts for each group of customers beginning with a certain number or letter (which can be listed multiple times with different invoice amounts). My problem is that when I want to add up all amounts for any codes starting with a number, it won't accept SUMIF(A:A,"6*,B:B) to add up all codes starting with 6, but it will accept SUMIF(A:A,"A*,B:B) for all codes starting with A. I can also have SUMIF(A:A,">0",B:B) and will add up all codes that are ALL NUMBERS starting with any number. But how do I SUMIF codes that start with a number but also contain letters?

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: sumif cell begins with a number but also contains letters

    It might make it easier to offer suggestions if members could see a sample workbook of the data you are working with (no sensitive info), and what your expected outcome would be
    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

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

    Re: sumif cell begins with a number but also contains letters

    Wildcards don't work on numbers.

    You can use the SUMPRODUCT function.

    =SUMPRODUCT(--(LEFT(A2:A10)="6"),B2:B10)

    Or, if you use a cell to hold the criteria:

    D2 = 6

    =SUMPRODUCT(--(LEFT(A2:A10)=TRIM(D2)),B2:B10)

    EDIT: You should avoid using entire columns as range references in the SUMPRODUCT function.
    Last edited by Tony Valko; 06-28-2013 at 08:15 PM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    07-20-2011
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: sumif cell begins with a number but also contains letters

    Quote Originally Posted by Tony Valko View Post

    =SUMPRODUCT(--(LEFT(A2:A10)="6"),B2:B10)
    This is perfect. I'll make sure to use a limited range instead of the entire column.

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

    Re: sumif cell begins with a number but also contains letters

    You're welcome. Thanks for the feedback!

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: sumif cell begins with a number but also contains letters

    oh yes they do =SUMIF(A:A,6&"*",B:B) oh oh no they dont my bad
    Last edited by martindwilson; 06-28-2013 at 09:28 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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