Results 1 to 6 of 6

Thread: Problems running SUMIF on a haystack of formulae

  1. #1
    Member
    Join Date
    Dec 02
    Posts
    49

    Resolved Problems running SUMIF on a haystack of formulae

    Hi all,

    I have a small problem and was looking for some help. Running Excel 2003.

    I have a sumif(needle, haystack, values) statement, where the needle is a long number, and the list of values in the haystack contains the needle. Yet the sumif does not retrieve the value for the needle in the haystack!

    ie. the needle is 112212397, and the haystack contains 112212397 with a value of £27,000. Yet, the statement returns £0.00. Breaking this down in the analyzer, it comes up with this:
    sumif(needle, #VALUE, values)

    In my experience, this usually means that there is a problem with the haystack. So looking at my haystack now, I can only see one problem - and that is that the 112212397 number in the haystack is actually =CONCATENATE((100+C3),(200+D3),(300+E3)).

    Is the fact that the haystack is a list of formulae messing up the SUMIF statement, and if so - how do I go about putting it right?

    Thanks in advance,

    Martin
    Last edited by Zukovsky; Aug 15th, 2012 at 02:54 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,524

    Re: Problems running SUMIF on a haystack of formulae

    number in the haystack is actually =CONCATENATE((100+C3),(200+D3),(300+E3)).
    i doubt that is the problem, your sumif formula must be wrong

    post the full formula, and the contents of relevant cells
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    Member
    Join Date
    Dec 02
    Posts
    49

    Re: Problems running SUMIF on a haystack of formulae

    OK, the sumif is as follows:

    =SUMIF(P100,Calculations!$F$3:$F$129,Calculations!$G$3:$G$129)

    where:

    P100 is: 106212397

    Calculations!$F$3 is: =CONCATENATE((100+C3),(200+D3),(300+E3))
    C3 is 6
    D3 is 12
    E3 is 97

    Calculations!$G$3 is: £23,742.40


    The result is £0.00

  4. #4
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,524

    Re: Problems running SUMIF on a haystack of formulae

    i think for what you are trying to do you try
    if( p100= Calculations!$F$3:$F$129,sum(Calculations!$G$3:$G$129),"")
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5
    Member
    Join Date
    Dec 02
    Posts
    49

    Re: Problems running SUMIF on a haystack of formulae

    Thanks for the answer, westconn1

    I tried what you suggested, but it just gives me a #Value error.

    Not sure i follow the logic of it either. What i'm trying to do is search for the value of P100 in the list of Calculations!$F$3:$F$129, and when it finds a match, to add the value from Calculations!$G$3:$G$129 with the same index. I'm quite certain I'm doing it right, in terms of sumif.

    I'm going to try doing it the long-winded way with OFFSET, MATCH, and INDEX to see if that will resolve the issue.

  6. #6
    Member
    Join Date
    Dec 02
    Posts
    49

    Re: Problems running SUMIF on a haystack of formulae

    OK,

    problem solved. Don't know why I didn't think of doing this yesterday, but I put in an OFFSET and a MATCH like so:

    =OFFSET(Calculations!$G$3,(MATCH(Permutations!J100,Calculations!$F$3:$F$129,0)-1),0)

    Thanks for your help. I'll drink more coffee next time before asking.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •