If then formulas - do they exist?

modano9

New Member
Joined
Dec 29, 2003
Messages
10
I'm trying to count the number of people in an age group, but only if another column is marked yes. Can anyone help me?

I thought I remembered somekind of if, then type of formula way back from my computer class days, but it's not working. Here's an example of what I thought it would be like...

If (E2:E50, "y"), then countif (F2:F50, ">18")

Any help would be appreciated!

Thanks!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
modano9 said:
I'm trying to count the number of people in an age group, but only if another column is marked yes. Can anyone help me?

I thought I remembered somekind of if, then type of formula way back from my computer class days, but it's not working. Here's an example of what I thought it would be like...

If (E2:E50, "y"), then countif (F2:F50, ">18")

Any help would be appreciated!

Thanks!

Try --

=SUMPRODUCT((E2:E50="y")*(F2:F50>18))

or even better --

=SUMPRODUCT(--(E2:E50="y"),--(F2:F50>18))
 
Upvote 0
Look up the parameters for the IF formula in the F1 help file.

You can construct something that will look for what you want to do.
It works exactly like an IF - Then Logical Formula.

(y)

Ooops, and someone beat me to the best option :oops:
 
Upvote 0
Must each cell in E2:E50 house a "y" or a single "y" anywhere in E2:E50 is sufficient for applying CountIf?
 
Upvote 0
just_jon,
I tried both your formulas, but they both continue to tell me there's an error, any suggestions?

Aladin,
each cell will either contain a Y or a N.

Thanks y'all!
 
Upvote 0
How about --

=SUMPRODUCT(--(E2:E50="y"),--(F2:F50>"18"))

what error are you getting? the =ISNUMBER bit is a test to see if column F contains true numbers, or text that happens to look like numbers.
 
Upvote 0
Chances are your entries in column F are text entries -- so how about if you try ...

=SUMPRODUCT((E2:E50="y")*(--(F2:F50)>18))
 
Upvote 0
modano9 said:
...each cell will either contain a Y or a N...

I believe I didn't get all the answers! Are you trying to count ages above 18 in one column whenever a "y" in the other column? If so, you are already given the formula you need.

=SUMPRODUCT(--(E2:E50="y"),--(F2:F50>18))

If not, please try to make explicit what you exactly want to count?
 
Upvote 0

Forum statistics

Threads
1,202,974
Messages
6,052,866
Members
444,605
Latest member
ExcelQA

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
Back
Top