+ Reply to Thread
Results 1 to 10 of 10
  1. #1
    Valued Forum Contributor
    Join Date
    08-28-2006
    Posts
    280

    Sumproduct returning zero

    I've written a sumproduct formula, which does what I want it to do; but it returns a zero in false condition, instead of a blank. I've tried several things, but don't seem to be progressing very far. Here's the formula that I ended up with. Can someone give me a push.

    Code:
    =SUMPRODUCT(--($A$8:$A$120=$A132),--($C$8:$C$120=$C132),--($E$8:$E$120)*D132)
    Thanks,

    Dean

  2. #2
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,009
    Not giving much away are you

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    9,506
    Quote Originally Posted by Dean England
    I've written a sumproduct formula, which does what I want it to do; but it returns a zero in false condition, instead of a blank. I've tried several things, but don't seem to be progressing very far. Here's the formula that I ended up with. Can someone give me a push.

    Code:
    =SUMPRODUCT(--($A$8:$A$120=$A132),--($C$8:$C$120=$C132),--($E$8:$E$120)*D132)
    Thanks,

    Dean
    SUMPRODUCT always returns a number (if not an error).If you want a blank then the easiest way is to format the cell, something like

    General;;

    then zero will look like blank. Or you could make yourself a nice long formula with

    =If(sumproduct_formula=0,"",sumproduct_formula)

  4. #4
    Valued Forum Contributor
    Join Date
    08-28-2006
    Posts
    280

    Talking Yes! Thank you.

    VBA Noob: Sorry for the brevity of the request. I sometimes get caught up in the problem and am either too brief or too long winded, but I do appreciate the help. I some times assume that since I know what I'm doing, everybody else does.

    Daddy Long Legs: I went with the long sumproduct formula, because of the small size of the workbook in this project. I had written the long version several times, but had used "" instead of zero in the logical test (assuming they were the same) and should have known better. Thanks for the explanation about the number-error thing with sumproduct. Even though I read the sumproducts piece at xldynamics; I must've missed that.

    So, one more question, for anyone out there, given my new formula:

    Code:
    =IF(SUMPRODUCT(--($A$8:$A$120=$A132),--($C$8:$C$120=$C132),--($G$8:$G$120)*$D132)=0,"",SUMPRODUCT(--($A$8:$A$120=$A132),--($C$8:$C$120=$C132),--($G$8:$G$120)*$D132))
    A8:A120 is are the Employee Numbers matched against the Employee Code in A132.
    C8:C120 are the Pay Rate Codes for those employees (each employee can have up to four distinct rates which is in C132.
    G8:G120 (actually columns E to S) are the number of hours worked each day of the pay period multiplied by D132 which is the actual amount for that pay rate.

    I can work with what I have, but my question is: Is there a more efficient way to accomplish this end. No rush here, I'm trying to pick your minds.

    Thanks again,

    Dean
    Last edited by Dean England; 01-09-2007 at 03:24 PM.

  5. #5
    Registered User
    Join Date
    03-17-2007
    Posts
    39

    Post Another angle

    Quote Originally Posted by daddylonglegs
    SUMPRODUCT always returns a number (if not an error).If you want a blank then the easiest way is to format the cell, something like

    General;;

    then zero will look like blank. Or you could make yourself a nice long formula with

    =If(sumproduct_formula=0,"",sumproduct_formula)
    when i searching the forum for my question, i thought the above may help me in solving the issue.

    In the above said sumproduct formula results 0, if the result is 0 (here we are considering blank cell as 0), if it is true then blank, if not then sumproduct formula

    but what if the sumproduct formula is really picks up "0" (as 0 is available in the source) instead of blank then how to handle can any one sort out this issue.
    thanks in advance
    DHARMO RAKSHATI RAKSHITAHA
    (PROTECT DHARMA, WILL PROTECTS YOU)

    VIJAY DSK

  6. #6
    Registered User
    Join Date
    03-17-2007
    Posts
    39

    Post Hello

    hi there,
    any one can throw some light on this and advice me the solution to sort out my query.

    any speedy help will be appreciated.

    Thanks in Advance.
    DHARMO RAKSHATI RAKSHITAHA
    (PROTECT DHARMA, WILL PROTECTS YOU)

    VIJAY DSK

  7. #7
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,212
    As daddylonglegs said (way back when), SUMPRODUCT will only return a number or an error. It doesn't return a blank cell, and it will only return a 0 when the result is actually 0.

    So if you use a SUMPRODUCT formula and you get a 0 result, it's either correct or your formula wasn't written correctly to get the result you were intending.

  8. #8
    Registered User
    Join Date
    03-17-2007
    Posts
    39

    Hello

    Thanks for the speedy help pjoaquin.

    i understood the meaning of your reply.

    any how my scenario is i need to lookup a value basing on two conditions from another sheet. i wrote a sumproduct formula and when the value is there then, the formula is getting the value (irrespective of 0 or 24 or 365 for example offcourse my data contains 0's as well). but if the cell is blank then the sumproduct formula is getting 0 instead of blank. i want to avoid this.

    hope i am clear in asking
    thanks in advance.
    DHARMO RAKSHATI RAKSHITAHA
    (PROTECT DHARMA, WILL PROTECTS YOU)

    VIJAY DSK

  9. #9
    Registered User
    Join Date
    03-17-2007
    Posts
    39

    Hello

    Any advice is really appreciable to my query
    TIA
    DHARMO RAKSHATI RAKSHITAHA
    (PROTECT DHARMA, WILL PROTECTS YOU)

    VIJAY DSK

  10. #10
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    9,506
    You can't really do this with SUMPRODUCT because when it returns zero there's no way of knowing whether the value found was 0 or blank. Try using a LOOKUP construction like

    =IF(LOOKUP(2,1/((A1:A10="x")*(B1:B10="y")),C1:C10)="","",LOOKUP(2,1/((A1:A10="x")*(B1:B10="y")),C1:C10))

    If you can't make that work post your current formula

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