Count nonblank cells except with certain criteria

L

Legacy 469449

Guest
Hi,

I'm trying to create a new rota for my workplace [Google Sheets – image below-

Picture 61.png


Column D needs to be a total number of nonblank cells, but only if they're not any of SICK, HOL, SAB, OFF, MAT, PAT, R/O. (So in that image, it would just be 4).

I'm currently using
Excel Formula:
=COUNTA(G16:AO16)-SUM(COUNTIFS(G16:AO16,{"SICK","HOL","SAB","OFF","MAT","PAT","R/O"}))
, which is working in not counting the SICK, but not anything else.

(I can't just ask it to count 12; 12.30; 1.30, as there will be far more criteria that could be added).

Thank you so much for any help you can give here
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
=COUNTA(G16:AO16)-sum(countif(G16:AO16,"SICK")+countif(G16:AO16,"HOL")+countif(G16:AO16,"SAB")+countif(G16:AO16,"OFF")+countif(G16:AO16,"MAT")+countif(G16:AO16,"PAT")+countif(G16:AO16,"R/O"))

Should work
 
Upvote 0
=COUNTA(G16:AO16)-sum(countif(G16:AO16,"SICK")+countif(G16:AO16,"HOL")+countif(G16:AO16,"SAB")+countif(G16:AO16,"OFF")+countif(G16:AO16,"MAT")+countif(G16:AO16,"PAT")+countif(G16:AO16,"R/O"))

Should work
That's brilliant, thank you!
 
Upvote 0
@rcp - if your question is answered, then that would be great if you could mark the solution post to help future readers.

Also, my approach to the question would be a shorter formula using the ARRAYFORMULA function as shown below.

By using the ARRAYFORMULA function in Google Sheets:
Excel Formula:
=COUNTA(G16:AO16)-ARRAYFORMULA(SUM(COUNTIF(G16:AO16,{"SICK","HOL","SAB","OFF","MAT","PAT","R/O"})) )

Or, by using SUMPRODUCT if you are trying to count numerics only:
Excel Formula:
=SUMPRODUCT(--ISNUMBER(G16:AO16))
Note that -- is necessary if you'd like to make the formula compatible with Excel as well.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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