+ Reply to Thread
Results 1 to 13 of 13

Sumif with about 1,000 criterias

  1. #1
    Registered User
    Join Date
    01-25-2010
    Location
    Joinville, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    42

    Sumif with about 1,000 criterias

    Hello,

    I need to sum up about 1000 different items from a .txt import, each with a unique itemcode. The item codes I would sum up are on a chart, so I can add new itemcodes I have to list when necessary.

    Currently the best I could come up with is use SUMIF + SUMIF + SUMIF + SUMIF... but I would have to do that about 1000 times.

    Any help is appreciated! I have included a sample excel sheet.

    Thanks in advance.
    Attached Files Attached Files
    Last edited by NBVC; 03-17-2010 at 03:38 PM.

  2. #2
    Forum Contributor
    Join Date
    03-12-2009
    Location
    Calgary, Canada
    MS-Off Ver
    Excel 365
    Posts
    236

    Re: Sumif with about 1,000 criterias

    I'm pretty sure I understood what you wanted. I have made the codes text which means they must be entered with a preceding apostrophe (i.e. the ') . I put conditional formatting on the codes to help you know when you have the same one more than once in your list. I put the totals to the left of the codes. I hope this is what you were looking for.
    Attached Files Attached Files
    If you can't figure out how a formula works, try stepping through it using "Evaluate Formula" in the Formula Auditing menu item in the tools menu!

    If you want to see where your code went wrong, try stepping through it by clicking in the code and pressing F8 and watch as the magic happens!


    If you are happy with any of the results, please add to the contributor's reputation by clicking the star icon.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sumif with about 1,000 criterias

    Why did you list repeat codes in your group1.. is that done purposely.

    If so, you should create a unique list with Data|Advanced Filter..

    then use something like:

    =SUMPRODUCT(SUMIF(A:A,J6:J1000,C:C))

    where J6:J1000 is a unique listing of codes to search...

    Adjust J6:J1000 to location of unique list.
    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.

  4. #4
    Registered User
    Join Date
    01-25-2010
    Location
    Joinville, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Sumif with about 1,000 criterias

    Thanks alot for the help guys! Sorry, I repeated the codes just for illustrative purposes. All of them are unique so they won't be repeated.

    Both these solutions you guys came up with work very well. NBVC it's amazing what can be done with SUMPRODUCT! I still don't understand why that formula should be working.

    I will keep this thread unsolved until I stress test this solution a bit.

  5. #5
    Registered User
    Join Date
    01-25-2010
    Location
    Joinville, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Sumif with about 1,000 criterias

    i have a problem with identifying the numbers I must sum by their codes.

    I am using the criteria of SUMIF as 2123*, in order to sum all the items that have codes that begin with 2123 (for example 2123100 - 2123199).

    The symbol * only works when there is text mixed in with the number. In my datasheet the codes sometimes appear without any text.

    What should I use in order for the SUMIF to sum all items with codes that start with 2123?

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sumif with about 1,000 criterias

    Something like

    =SUMPRODUCT(--(LEFT(A:A,4)="2123"),C:C)

    Or you can convert the column to text

    Select column and go to Data|Text to Columns and skip to the 3rd dialogue window... choose Text from the column data format section.

    Now you can use SUMIF with the wildcard...

  7. #7
    Registered User
    Join Date
    01-25-2010
    Location
    Joinville, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Sumif with about 1,000 criterias

    Hmm I've been trying to get your formula to work for a while now with no success. Here is what I'm using

    =SOMARPRODUTO(--(ESQUERDA($A:$A;4)=$G$1:$G$4);$C:$C)

    =SOMARPRODUTO(--(ESQUERDA($A:$A;4)="2123");$C:$C) doesn't work either.

    maybe the "--" is something else in portuguese?

    As for my previous formula using *, I tried formatting the column to text but that doesn't help either. However, if I write some gibberish after the number, it works.
    Last edited by FortuneSyn; 03-17-2010 at 01:53 PM.

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sumif with about 1,000 criterias

    Are you in 2003 or 2007?

    2003 doesn't allow whole column references such as A:A with this formula.

  9. #9
    Registered User
    Join Date
    01-25-2010
    Location
    Joinville, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Sumif with about 1,000 criterias

    I am in 2007

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sumif with about 1,000 criterias

    Perhaps attach the workbook... the formulas will translate to me automatically... if there is a problem and I can fix it, when I attach it back it should translate back to your language.

  11. #11
    Registered User
    Join Date
    01-25-2010
    Location
    Joinville, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Sumif with about 1,000 criterias

    Here you go! The formula is in cell H5
    Attached Files Attached Files

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Sumif with about 1,000 criterias

    I did not realize you were still trying to match with a group of numbers....

    I used this formula:

    =SUMPRODUCT(--ISNUMBER(MATCH(LEFT(A:A,4)&" ",$J$6:$J$30&" ",0)),D:D)

    Note, though, this is quite resource intensive and you should try not to use whole column references for this kind of work... try shortening the ranges to max you think you will need.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-25-2010
    Location
    Joinville, Brazil
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Sumif with about 1,000 criterias

    Thanks alot! Works perfectly. I'll leave positive feedback when i get home (blocked address at work)

+ 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