# If then formulas - do they exist?

#### modano9

##### New Member
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))

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.

Ooops, and someone beat me to the best option

Must each cell in E2:E50 house a "y" or a single "y" anywhere in E2:E50 is sufficient for applying CountIf?

just_jon,
I tried both your formulas, but they both continue to tell me there's an error, any suggestions?

each cell will either contain a Y or a N.

Thanks y'all!

What does the below return --

=ISNUMBER(F2)

Don't know what you mean

=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.

Chances are your entries in column F are text entries -- so how about if you try ...

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

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?

Replies
1
Views
164
Replies
9
Views
227
Replies
11
Views
347
Replies
6
Views
196
Replies
1
Views
160

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.

### Which adblocker are you using?

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

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