+ Reply to Thread
Results 1 to 14 of 14

Last Row of SUMPRODUCT

  1. #1
    Registered User
    Join Date
    11-17-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    6

    Last Row of SUMPRODUCT

    I've been everywhere online I can think of to no avail. I'm attempting to return only the last value of a sumproduct's result. (read: last row).

    For example:

    =SUMPRODUCT(--($C$2=BCBS!A:A),--("_"=BCBS!B:B),--(BCBS!C:C=MAX(BCBS!C:C)),BCBS!E:E)

    This works for values that match A and B that have multiple results in C (it returns the value in E for the highest row number). However, it does not work with values that match A and B that only have a single result in C.

    Any ideas on this approach or another?
    Last edited by jerm_e; 11-17-2011 at 11:47 PM.

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

    Re: Last Row of SUMPRODUCT

    Maybe you want:

    =LOOKUP(2,1/(($C$2=BCBS!A:A)*("_"=BCBS!B:B)*(BCBS!C:C=MAX(BCBS!C:C))),BCBS!E:E)

    You should try not to use whole column references with these types of formulas as they are slow to process....
    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.

  3. #3
    Registered User
    Join Date
    11-17-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Last Row of SUMPRODUCT

    Number 1: Thank you for replying. I had zero luck elsewhere in trying to garner some sort of idea/response.

    Number 2: Your formula is picking up the correct values when there are multiple values in Column C, but when there is only a single result (i.e. the original sumproduct only has one row to look at), it still returns #N/A.

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

    Re: Last Row of SUMPRODUCT

    I am not quite sure I understand. Can you give example of what you mean by there is only a single result and it giving you #N/A error?

  5. #5
    Registered User
    Join Date
    11-17-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Last Row of SUMPRODUCT

    Sheet BCBS Contains The following Information:

    A..................B.............C......................D................................................E

    86780............_ ............7/1/2011............TREPONEMA PALLIDUM............20
    90732............_ ............7/15/2011..........PNEUMOCOCCAL VACCINE.........2
    90732............_ ............10/15/2011........PNEUMOCOCCAL VACCINE......64.75

    $C$2 on the CALC/home sheet contains a 5 digit number to lookup. If I lookup 90732 I return 64.75 (correct). When I lookup 86780 I return #N/A (incorrect). Does this help you? I can give you more info if needed.
    Last edited by jerm_e; 11-17-2011 at 11:34 PM.

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

    Re: Last Row of SUMPRODUCT

    If your looking for the last, maybe we don't need to look for max...

    i.e.

    =LOOKUP(2,1/(($C$2=BCBS!A:A)*("_"=BCBS!B:B)),BCBS!E:E)

  7. #7
    Registered User
    Join Date
    11-17-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Last Row of SUMPRODUCT

    That seems to be doing the trick! Will this handle things if there are 3, 4, or 5 additional occurrences of 90732? i.e. Will it always return the final row's value?

  8. #8
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Last Row of SUMPRODUCT

    Try this,

    =LOOKUP(9E300,SEARCH(C2,BCBS!A2:A30)*SEARCH("_",BCBS!B2:B30),BCBS!E2:E30)
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

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

    Re: Last Row of SUMPRODUCT

    Yes it should.

    Lookup(2,1/.....) looks for last occurance of the combined conditions....

  10. #10
    Registered User
    Join Date
    11-17-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Last Row of SUMPRODUCT

    Amazing. After 4 hours research, I find someone who can show it, do it, and teach it in 4 minutes. Thank you for your help.

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

    Re: Last Row of SUMPRODUCT

    You are welcome

    Remember that whole column usage in this formula will slow down the spreadsheet processing.. Try using a defined range.
    Last edited by NBVC; 11-17-2011 at 11:55 PM.

  12. #12
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Last Row of SUMPRODUCT

    also try
    =MAX(INDEX(((BCBS!A1:A10=$C$2)*(BCBS!$B$1:$B$10="_")*BCBS!E1:E10),0))
    Azam
    If you want to say Thank you to a member, click the reputation icon (Star) in the left bottom of the post.
    For prompt answer, be descriptive, concise, short, direct, and to-the-point.

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

    Re: Last Row of SUMPRODUCT

    That will pick up the max value in column E with the combined conditions, not necessarily the last row containing the combined conditions.

  14. #14
    Registered User
    Join Date
    11-17-2011
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Last Row of SUMPRODUCT

    I'll define some ranges to make things run a bit better. It is a little clunky, but quite acceptable for its current use. Thanks again!

+ 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