# Thread: =SUMIF question ('97, SR-2)

1. ## =SUMIF question ('97, SR-2)

How do I do a SUMIF where the condition refers to a value in another cell?

(I want to do it this way so that I can change the value easily without editing the SUMIF entry.)

It seems to want the condition to be in the form of ">51" (including the quotes).

I want to give it: >AA12

Any help would be appreciated.

2. ## Re: =SUMIF question ('97, SR-2)

Use the concatenation operator &:

">"&AA12

3. ## Re: =SUMIF question ('97, SR-2)

Once again...worked like a charm.

Muchos gracias!

4. ## Re: =SUMIF question ('97, SR-2)

Hans,
Just out of curiosity, how can ordinary people find this out? It's not in Help. Is there a sort of Super-Help somewhere, or is this Lounge it (or more precisely, you, Steve, Jan and the others?)

5. ## Re: =SUMIF question ('97, SR-2)

I agree with all your points.

I learn many things in the playing to try to answer the questions posed. Some of the answers I know, others I have a clue, there are some I have no idea. I just experiment and work it out. My philosophy is to assume there is a way to do it and then try to find it.

Steve

6. ## Re: =SUMIF question ('97, SR-2)

(Edited by HansV to update link to Excel MVP site)

I guess it's a combination of a lot of things:
- Logical thinking
- Willingness to experiment
- Word of mouth from experienced users
- Knowledge Base
- Newsgroups (searchable by Google)
- Mailing lists
- Dedicated websites (Chip Pearson, John Walkenbach, Excel MVP page, ...)
- And, of course, the Lounge (I learn something new here every day)

7. ## Re: =SUMIF question ('97, SR-2)

Hans, is there a way of doing a SUMIF with an AND?

I cant find one, but want the following

=SUMIF( range1, ">" & cell1 AND "<" & cell2, range2)

to acheive this i have done two sum ifs, one on each of the cells, and then subtracted one from the other to give the correct result, but was wondering if there was an 'AND' function that allowed for this. I know the AND function is a boolean, so I dont think I can use this.

Thanks

8. ## Re: =SUMIF question ('97, SR-2)

Try SUMPRODUCT((Range1>A1)*(Range1<B1)*(Range2))

9. ## Re: =SUMIF question ('97, SR-2)

Ah, I think I have not communicated what I wanted to do.

I want to sum values in range2 only if the values in range1 are greater than cell1 and less than cell2. Or to put it another way, if the values in range 1 are between certain values.

I wonder if I could use an array formula? I dont really understand what array formulas are

<img src=/S/coffeetime.gif border=0 alt=coffeetime width=32 height=48>

10. ## Re: =SUMIF question ('97, SR-2)

The SUMRPODUCT will do that. (I used A1 for Cell 1 and B1 for Cell 2).

11. ## Re: =SUMIF question ('97, SR-2)

Shades' formula

=SUMPRODUCT((Range1>A1)*(Range1<B1)*(Range2))

should do what you want, or alternatively

=SUM((Range1>A1)*(Range1<B1)*(Range2))

entered as an array formula, i.e. confirm with Ctrl+Shift+Enter instead of just Enter. Explanation: an expression such as Range1>A1 results in an array of TRUE/FALSE values. The formula uses the fact that TRUE = 1 and FALSE = 0. Perhaps this table with intermediate results helps:

<table border=1> <td>Range1</td> <td>Range1>Cell1</td> <td>Range1<Cell2</td> <td>(Range1>Cell1)*(Range1<Cell2)</td> <td>Range2</td> <td>(Range1>Cell1)*(Range1<Cell2)*Range2</td> <td align=right>1</td> <td align=right>FALSE</td> <td align=right>TRUE</td> <td align=right>0</td> <td align=right>2</td> <td align=right>0</td> <td align=right>2</td> <td align=right>FALSE</td> <td align=right>TRUE</td> <td align=right>0</td> <td align=right>4</td> <td align=right>0</td> <td align=right>3</td> <td align=right>TRUE</td> <td align=right>TRUE</td> <td align=right>1</td> <td align=right>8</td> <td align=right>8</td> <td align=right>4</td> <td align=right>TRUE</td> <td align=right>TRUE</td> <td align=right>1</td> <td align=right>16</td> <td align=right>16</td> <td align=right>5</td> <td align=right>TRUE</td> <td align=right>TRUE</td> <td align=right>1</td> <td align=right>32</td> <td align=right>32</td> <td align=right>6</td> <td align=right>TRUE</td> <td align=right>FALSE</td> <td align=right>0</td> <td align=right>64</td> <td align=right>0</td> <td align=right> </td> <td align=right> </td> <td align=right> </td> <td align=right> </td> <td align=right> </td> <td align=right> </td> <td>Cell1</td> <td align=right>2</td> <td align=right> </td> <td align=right> </td> <td>Sum</td> <td align=right>56</td> <td>Cell2</td> <td align=right>6</td> <td align=right> </td> <td align=right> </td> <td align=right> </td> <td align=right> </td> </table>

12. ## Re: =SUMIF question ('97, SR-2)

Another array (my preference, since it allows one to use the other stat functions, count, average, stddev, min, max, etc) is (confirm with ctrl-shift-enter)
<pre>=SUM(if((Range1>A1)*(Range1<B1),Range2))</pre>

Steve

13. ## Re: =SUMIF question ('97, SR-2)

Or a "creative application of the feature set" <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

14. ## Re: =SUMIF question ('97, SR-2)

Thanks !

I understand now (thanks Hans) the True and False multiplied to either sum the range or not.

Thats great stuff [img]/forums/images/smilies/biggrin.gif[/img]

#### Posting Permissions

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