negative countifs

Andy83UK

Board Regular
Joined
Jun 4, 2010
Messages
142
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
For your help.
 

Some videos you may like

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,067
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Try:
=COUNTA(B2:B14)-COUNTIF(B2:B14,"e")-COUNTIF(B2:B14,"f")
 

Andy83UK

Board Regular
Joined
Jun 4, 2010
Messages
142
Sorted!

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

Thanks
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,067
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
You could also use:
=COUNTA(B2:B14)-SUM(COUNTIF(B2:B14,{"e","f"}))
if you wanted.
 

Andy83UK

Board Regular
Joined
Jun 4, 2010
Messages
142

ADVERTISEMENT

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

Andy83UK

Board Regular
Joined
Jun 4, 2010
Messages
142
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?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,067
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS

ADVERTISEMENT

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?)?
 

Andy83UK

Board Regular
Joined
Jun 4, 2010
Messages
142
i am trying

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

where A6 = Dee
 

Andy83UK

Board Regular
Joined
Jun 4, 2010
Messages
142
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.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,067
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Something like:
=SUMPRODUCT(($A$2:$A$10="Dee")*ISNA(MATCH($B$2:$B$10,{"e","f"},0))*($B$2:$B$10<>""))
 

Watch MrExcel Video

Forum statistics

Threads
1,122,517
Messages
5,596,620
Members
414,081
Latest member
Subaru_Steve

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