Need help with IF formula

wislndixie

New Member
Joined
Feb 13, 2004
Messages
23
I've created a very simple spread sheet but I need help creating a IF formula that will calculate:
Cell J2 is a "y" or "n" value.
I want my formula to SUM f2:h2 if the value in J2 is y
I want my formula to SUM f2:g2 if the value in J2 is n

I tried this:
=if(J2=y,sum(f2:h2),sum(f2:g2))
I just get a zero in the cell that I type the formula.
I am using Excel 97.

thanks,
Wisln
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

TryingToLearn

Well-known Member
Joined
Sep 10, 2003
Messages
723
Try:

=if(J2="y",sum(f2:h2),sum(f2:g2))


y is a string needing quotes rather than a variable
 

wislndixie

New Member
Joined
Feb 13, 2004
Messages
23
Oh man, you guys are geniuses..thanks for the help. It worked perfect. I'm sure I'll be back with more questions..
Wisln
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,322
Messages
5,769,453
Members
425,548
Latest member
macjagger17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top