View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
RagDyeR RagDyeR is offline
external usenet poster
 
Posts: 3,572
Default Criteria Syntax in SUMIF formula

To answer your basic question about multiple criteria for the Sumif()
function, the answer is *yes*.

You wrap the Sumif() in the Sum() function, and you use an array constant
for the criteria:

=Sum(Sumif(A1:A10,{25,50,75},B1:B10))
=Sum(Sumif(A1:A10,{"Tom","Dick","Harry"},B1:B10))

However, array constants will *not* accept cell references.

You therefore must include the Indirect() function to use cell references.

As in my earlier example:

=SUM(SUMIF(A2:A10,T(INDIRECT({"C1","D1"})),B2:B10) )

Using either a "T" or "N" to denote the contents of the cells being used as
the criteria.
--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===



"RollieG" wrote in message
...
Thank you, but I just wanted to know one thing:

Can the criteria in a SUMIF refer to one of two (or more) values?


"John C" wrote:

You could always change up the formula a little bit. Assuming you have the
day of the month in a column, you could always combine the formula with
indirects:
=IF(ISBLANK(INDIRECT("'"&A10&"'!$AS$2:$AS$5000")), "",SUMIF(INDIRECT("'"&A10&"'!$AS$2:$AS$5000"),$C$2 ,INDIRECT("'"&A10&"'!$AT$2:$AT$5000"))+SUMIF(INDIR ECT("'"&A10&"'!$AS$2:$AS$5000"),$K$1,INDIRECT("'"& A10&"'!$AT$2:$AT$5000")))
This would be the formula for row 10 (assuming you have header information
above like in C2 and K1. This also assumes your day numbering is in column
A.
Modify as needed. You could also use different methods to generate the tab
name, for example, instead of A10 for the 1 tab, you could use ROW()-9 in
place, and that will evaluate to 1.
--
** John C **

"RollieG" wrote:

Thank you, but this is what I want to do:

Here is the actual formula that I need to change:

=IF(ISBLANK('29'!$AS$2:$AS$5000),"",SUMIF('29'!$AS $2:$AS$5000,$C$2,'29'!$AT$2:$AT$5000)).

I want to use the Find and Replace function to replace the criteria
"$C$2"
with the desired expression ($C$2 or $K$1).

I didn't originally design this worksheet, and I am stuck with the
original
logic. There are actually over 150 tabs with 31 formulas on each sheet
to
change. I wanted to use the Repace all function, selecting multiple
sheets
(tabs), so I can change all the formulas at one time.

Changing it with your suggestion would mean, if I am understanding you
correctly, would change the formula to :

=IF(ISBLANK('29'!$AS$2:$AS$5000),"",SUMIF('29'!$AS $2:$AS$5000,$C$2,'29'!$AT$2:$AT$5000+SUMIF('29'!$A S$2:$AS$5000,$K$1,'29'!$AT$2:$AT$5000))

The Sheet tab '29" refers to a sheet with data from the 29th of the
month.
The next formula on the next row is:

=IF(ISBLANK('30"AS$2:$AS$5000),"",SUMIF('30'S$2:$A S$5000,$C$2,'29'!$AT$2:$AT$5000)).

This is why I would like to change the formula using the Find and
Replace
method.


I thought there could be an expression in the criteria part of the
formula
that refers to one of two or more values.
"Gary''s Student" wrote:

Just add them:

=SUMIF() + SUMIF()
--
Gary''s Student - gsnu200810


"RollieG" wrote:

How do you use SUMIF, when your criteria is one of two(or multiple)
values?

For Example, I want to use:

=SUMIF(A2:A10, ($C$1 or $D$1), B2:B10), but I know ($C$1 or $D$1) is
not the
correct syntax.