sumif wrong result

T

tallyman00

I am trying to sum cells across a row, if the corresponding cell i
another row, the same column, has an “A”. I am getting incorrec
results. Why? Here is my formula: =SUMIF($C$4:$N$4,"A",C9:N9)

Thank
 
B

Bob Phillips

It works fine in my tests. What data gives incorrect results?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
B

Bernard Liengme

This works for me. I tried =SUMIF($C$4:$G$4,"A",C9:G9)
What is wrong with the result?
Could it be that one or more "A" values are in fact something like "A ";
try =SUMPRODUCT(--(TRIM(C4:G4)="A"),C9:G9)

Could one or more numbers actually be text? Try in a helper row
=ISNUMBER(C9) .... etc
 
T

tallyman00

This spreadsheet is budget that shows projected and actual
expenditures.
On Row 4 I have either an "A" or a "P" for each month of the year. For
rows below 4 I have different types of expenditures. They are all
numbers. For each of those rows I am testing the corresponding cell on
row 4 to see if it is an "A" or "P". If I just do a sum for the columns
that I know that I have an "A" or use my calculator, I get a different
result than when I use sumif. I don't understand why sumif isn't giving
me accurate data.
 
B

Bob Phillips

Can you give us the data and tell us what answer that you get so that we can
test it?

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
T

tallyman00

Thank you everybody for your help. Apparently their was something other
than just an “A” in one or more of my test columns. When I used
Bernard’s formula with the sumproduct and trim, it worked perfectly. I
tried to use the trim in the sumif, but I guess that I didn’t have the
format right. In any event, when I went back and put a new “A” in each
column, then sumif worked correctly too.
 
Top