+ Reply to Thread
Results 1 to 10 of 10

Thread: "Sumif" modification

  1. #1
    Registered User
    Join Date
    12-23-2009
    Location
    SERBIA
    MS-Off Ver
    Excel 2003
    Posts
    70

    "Sumif" modification

    Please guys help me, now I have this formula:

    =Sumif($A$34:$J500,C4,$L$34:$L$500)

    As you can see now when i execute my formula I would pick up in the column L all numbers when in column A was value from the cell C4, can you do modification and take from the column L only last 6 times when C4 would be matched in the column A.

    Thank you a lot in advance.

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,616

    Re: "Sumif" modification

    Try:

    =SUM(IF($A$34:$J500=C4,IF(ROW($A$34:$J500)>=LARGE(IF($A$34:$J500=C4,ROW($A$34:$J500)-ROW($A$34)+1),6),$L$34:$L$500)))

    confirmed with CTRL+SHIFT+ENTER not just ENTER.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Registered User
    Join Date
    12-23-2009
    Location
    SERBIA
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: "Sumif" modification

    Thank you a lot,but for some reason this formula not worked on the my sheet.

    I made one simple sample maybe could help you..
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: "Sumif" modification

    That is because you did not mention that your criterion could appear in one of several columns. In your example, could you have T in both columns on the same row?
    Good luck.

  5. #5
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,053

    Re: "Sumif" modification

    I think NBVC's formula accounts for multiple rows........but the last ROW function shouldn't be there, so applied to your small sample formula should be

    =SUM(IF($B$5:$D$13="T",IF(ROW($B$5:$D$13)>=LARGE(IF($B$5:$D$13="T",ROW($B$5:$D$13)),6),$E$5:$E$13)))

    confirmed with CTRL+SHIFT+ENTER

    Clearly your sample has only 6 "T"s but that formula should only count the last 6 rows if you have more. It might not work as you want if there can be multiple instances of "T" in a single row as 0EGO suggests, is that a possibility? What should happen in that case?

    The above formula will also fail if there are fewer than 6 instances...is that possible?
    Audere est facere

  6. #6
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: "Sumif" modification

    Quote Originally Posted by daddylonglegs View Post
    I think NBVC's formula accounts for multiple rows
    You are of course correct. I admit that having noticed that the original SUMIF was flawed (I wonder what is in columns M-U), I assumed the multiple column range in the first argument was a typo and did not really look at the references in NBVC's formulas.
    Good luck.

  7. #7
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,053

    Re: "Sumif" modification

    D'oh!

    Of course I meant multiple columns.....but you knew that...

    Quote Originally Posted by OnErrorGoto0 View Post
    I admit that having noticed that the original SUMIF was flawed (I wonder what is in columns M-U),
    Yes, you're right. It's not clear if the intent is to sum those columns too - I suspect it isn't - text implies only summing L based on A
    Audere est facere

  8. #8
    Valued Forum Contributor OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,647

    Re: "Sumif" modification

    Indeed - that is what threw me with the example. It seems to confirm that the original SUMIF formula was not a typo, just an incorrect formula, since it will include columns M-U in the sum range, whereas the intent seems to be a multi-column criteria range but single column sum range.
    Good luck.

  9. #9
    Registered User
    Join Date
    12-23-2009
    Location
    SERBIA
    MS-Off Ver
    Excel 2003
    Posts
    70

    Re: "Sumif" modification

    Ok guys, first of all thank you for your effort to help me, yes you have a right “sample” and first post on the forum are different, here is only relevant the “sample” document .

    In my document I have mere then six “T” in both column (B and D), there is not possible to happened multiple of “T” in same raw.

    Main wish is to take all numbers in E column when “T” would be located in the column B or column D but not all than only last six times (there is no matter which columns contain D or B).

    I hope that I now made a little more clear situation.

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

    Re: "Sumif" modification

    Did you try daddylongleg's correction to my formula... you need to confirm with CTRL+SHIFT+ENTER not just ENTER to make it work.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

+ 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.2.0