Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SUMPRODUCT Question 3

Status
Not open for further replies.

NumberCrunchingMonky

Technical User
Feb 5, 2004
30
US
I'm using SUMPRODUCT and need to exclude a particular variable from my SUMPRODUCT criteria. How do I do this?

For example, I have a table of all cities(col.A) in all states(col.B) in the US. There's also a field with the population of each state(col.C).

If I wanted to Sum the population of all cities in the state of California I would do something like this (given there are named ranges for "City", "State", "Population").

=SUMPRODUCT((State="California")*(Population))

But what if I wanted to sum the population of the state of California, minus, say, San Francisco? Being there are too many cities in the state to specify in the formula individually I need to exclde "San Francisco" another way formulaically.

So, the formula couldn't look like this:
=SUMPRODUCT(((City="Alameida")+(City="Sacramento")+(City="Los Angeles")+(etc.)+(etc.))*(State="California")*(Population))

How do I do this?

Thank you.

Monky
 

Something like
Code:
  =SUMPRODUCT("state of CA") - SUMPRODUCT("San Francisco")
But I would probably use DSUM in a case like this.


 
=SUMPRODUCT((State=&quot;California&quot;)*(City<>&quot;San Francisco&quot;)*(Population))

Regards
Ken................


----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
I have a worksheet using SUMPRODUCT that works fine with the array defined as cell ranges, but when I name the array as a range, it won't work. Any ideas?
 
the named range should NOT include the headers and shouldn't be the whole column. If your ranges include either of these, they need re-defining

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Thanks, xlbo
No...the range does not include a heading nor is it the full column...it does include some blank cells at the bottom of the range.
 
The ranges MUST be exactly the same length.

Regards
Ken.................

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Ken
Zathras

Your suggestions both work very well. Many thanks for your help. And I'll check out DSUM in future situations.

Thanks,

NCM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top