# negative countifs

#### Andy83UK

##### Board Regular
I am trying to use a formula to count a large number of occurences on a spreadsheet subtracting away a couple of variables, so far I haven't been able to acheive this on a test sheet.

The formula I'm trying to make work is

=COUNTA((B2:B14))-COUNTIFS(B2:B14,"e",B2:B14,"f")

I think that is basically doing what I require as I want to toal up a much larger sheet of a couple of thousand rows of info minusing away any with the criteria of e and f.

Thanks

### Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Try:
=COUNTA(B2:B14)-COUNTIF(B2:B14,"e")-COUNTIF(B2:B14,"f")

Sorted!

Thanks very much for your help, knew it would be something simple i'd done wrong!

Thanks

You could also use:
=COUNTA(B2:B14)-SUM(COUNTIF(B2:B14,{"e","f"}))
if you wanted.

thanks that second one may be simpler in longer formulas of which this will likely be a part i think.

Is there a way to have this formula work with an if criteria before it?

such as if \$M:\$M = Dee then perform this action?

I think you'd need SUMPRODUCT for that. Do you mean count where M is "Dee" and B is not "e" or "f" (can B be blank?)?

i am trying

=IF(\$A:\$A=A6,"")*(COUNTA(B2:B14)-COUNTIF(B2:B14,"e")-COUNTIF(B2:B14,"f"))

where A6 = Dee

Yes B could possibly be blank but shouldn't M could be a variety of possibilities including a lot of blanks but I would change the formula's entry for M's criteria as needed.

the formula where i've been using Columns A and B is just on a blank test sheet.

Something like:
=SUMPRODUCT((\$A\$2:\$A\$10="Dee")*ISNA(MATCH(\$B\$2:\$B\$10,{"e","f"},0))*(\$B\$2:\$B\$10<>""))

Replies
1
Views
214
Replies
3
Views
66
Replies
3
Views
195
Replies
2
Views
219
Replies
4
Views
175

1,217,503
Messages
6,137,016
Members
450,038
Latest member

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