# Count only if

#### rinnue

##### Board Regular
A________________B
Manager__________3
Laborer___________3
Manager _________N/A
Foreman__________2

I want to find the average of the Manager numbers. I am using Sumif to add the numbers in column B corresponding to Manager in column A, but what do I use to find the number to divide by? I need to count the number of occurances of "Manager", but only if they have corresponding numbers. Hope this makes sense. If only Countif workeed like Sumif......

### Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

If there are #N/As in the range as shown then perhaps

=AVERAGE(IF(ISNUMBER(B1:B4),IF(A1:A4="Manager",B1:B4)))

confirmed with CTRL+SHIFT+ENTER

or if you want to count the #N/A as a zero (to give a result of 1.5 rather than 3)

=AVERAGE(IF(A1:A4="Manager",IF(ISNUMBER(B1:B4),B1:B4,0)))

also confirmed with CTRL+SHIFT+ENTER

I would expect it to be 3 since there is no data, or N/A, in one of the manager fields. Didn't know there was an Average function. I will play with that and see what I can get. Thanks.

Not sure why but I get a 0 when I use either formula. I set my data in columns A and B exactly like I posted.

Now some of my columns of data I want to use this in are not adjacent to each other. Not sure if that will matter in the future.

Is there no function for counting that has syntax like SumIf?

Well, you can use COUNTIF....

one of the ways to do what you ask, usually is

=SUMIF(A1:A4,"Manager",B1:B4)/COUNTIF(A1:A4,"Manager")

but this won't work if you have errors in your ranges.

What formula did you try?

note: it shouldn't matter whether the columns are adjacent or not

For the CountIf formula, that is exactly what I tried and the problem was that any errors(N/A) in the data were processed like zeros, however i need the bad data ignored.

I tried both of the formulas you posted and both = 0.

I appreciate your help and I apologize for making this difficult. I am by no means an Excel wiz though.

You have to confirm the formula with CTRL+SHIFT+ENTER so that curly braces appear around the formula in the formula bar.

To do this.....

Select cell with formula
Press F2
Hold down CTRL and SHIFT keys at the same time and whilst doing so...
...press ENTER

should look like this
workday.xls
ABCDE
1Manager3
2Laborer33
3Manager#N/A
4Foreman2
5
Sheet4

Formula in D2

=AVERAGE(IF(ISNUMBER(B1:B4),IF(A1:A4="Manager",B1:B4)))

Seems to be working great!!!!

So why is the confirming step needed? Other formulas I have work fine. Is this a special formula?

Replies
5
Views
129
Replies
10
Views
249
Replies
1
Views
115
Replies
2
Views
231
Replies
11
Views
352

1,219,808
Messages
6,150,353
Members
450,954
Latest member
Vd1408

### 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