if/countif

kelvin_9

Active Member
Joined
Mar 6, 2015
Messages
444
Office Version
  1. 2019
​hello all, can i use just 1 formula to return my request if i want to calculate how many staffs will work before 13:00 / after 13:00?
PS:
use M=Morning on before 13:00
use N=Night on after 13:00
if cell blank, no return, no count

=IF((LEFT(A2,5)<"13:00"),"M","N")
=COUNTIF(B2:B6,"M")

timebefore / after 13:00
14:15 - 22:45N
10:00 - 19:30M
13:00 - 20:30N
15:30 - 22:45N

<tbody>
</tbody>

M1
N3

<tbody>
</tbody>

thanks,
kelvin
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Try

=SUMPRODUCT(--(LEFT(A2:A6,5)+0 < TIMEVALUE("13:00"))

You cant use LEFT(range...) in a COUNTIF hence the SUMPRODUCT
 
Last edited:
Upvote 0
Try

=SUMPRODUCT(--(LEFT(A2:A6,5)+0 < TIMEVALUE("13:00"))

You cant use LEFT(range...) in a COUNTIF hence the SUMPRODUCT

brilliant special-k99
however, how can i skip the blank cell if there have 1 or more blank cell in a column?
ps: result turns to #value
 
Upvote 0
Hi, here is another option you can try:


Excel 2013/2016
AB
1timebefore / after 13:00
214:15 - 22:45N
310:00 - 19:30M
4
513:00 - 20:30N
615:30 - 22:45N
7
8M1
9N3
Sheet1
Cell Formulas
RangeFormula
B8=COUNTIFS($A$2:$A$6,"<13:00 - 00:00",$A$2:$A$6,"??:?? - ??:??")
B9=COUNTIFS($A$2:$A$6,">=13:00 - 00:00",$A$2:$A$6,"??:?? - ??:??")
 
Last edited:
Upvote 0
The #VALUE error
Aww, its cos the range is a mixture of text (blank rows) and numbers, SUMPRODUCT doesnt like a range that doesnt include all numbers

Deleting the blank row results in a number not a #VALUE error.
 
Last edited:
Upvote 0
what if I can't deleting any blank cell in a column?
The column I return my team's schedule, and final step would be easier to check out how many M/N over 100 staff in a column
Hope this can be fixed

Thanks special-k99
 
Upvote 0
formR
I apologize for the mistake
Your suggestion is brilliant and exactly what I want
thank you very much
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,369
Members
449,080
Latest member
Armadillos

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