If A without B, then C / Employees currently on break based on break list schedule.

Olisthoughts

New Member
Joined
Apr 16, 2020
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm making a break list at my new job for my team.

Because the list has multiple entries we are forced to concentrate unnecessarily to calculate how many agents are on break. It would be helpful for my colleagues to see how many agents are on break right now, since we have a rule of no more than 3 agents on break at the same time.

As you'll see in the screenshot, the agents can double-click on a cell for time input under Start time, and double-click on actual return time when they're back.

I'm assuming the way to do it is count the number of agents (rows) that have a value in start time with no value in return time, as that would be an indicator they're on break.

But no matter how I tried I couldn't figure it out. The closest I got was a formula that in pseudo code, basically said If start time + End time equals 1, then 1 agent on break, else nothing. However when more than 1 person was on break it would show 11 instead of 2.

For context, I will attach the codes I'm using (that are working), a screenshot or two, and also, for information, after an agent enters a value in start time or end time, those cells are locked. The estimated return time and actual break time are alway
Screenshot_38.png
Screenshot_38.png
s locked. And there are actually 15 agents on the team, I've only added 4 to work with.

Codes:


Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range
Dim cell As Range

' See if updated cells in watched range
Set rng = Intersect(Target, Range("c:u"))

' Loop through cells in watched range
If Not rng Is Nothing Then
For Each cell In rng
If cell <> "" Then
ActiveSheet.Unprotect Password:="Break"
cell.Locked = True
ActiveSheet.Protect Password:="Break"
End If
Next cell
End If

End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("c:u")) Is Nothing Then
Cancel = True
Target.Formula = Time
End If
End Sub
 
OK
SO
=(COUNTIFS($C4:$C4,"<>"&"",$E4:$E4,"")
that will count if the starttime has a value and the end time does not - for column C and D
so a 0 or a 1
will result
Then we add
the next set of breaks
COUNTIFS($H4:$H4,"<>"&"",$J4:$J4,"")
again a zero or a 1
so if there is a start date for C and no end date - that gives a 1
and
so if there is a start date for H and no end date - that gives a 1
Add them together =2
Hence the less than 2
as we should only have no start and blank ends or just 1

data validation - is then TRUE for 0 and 1
and allows entry
BUT when you add the 2nd entry - that will count to 2 and so FALSE and then the validation kicks in
a bit messy and maybe a betterway
BUT it works on the sample drop box i posted
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Ok, I'll try to figure that one out.
Now I'm trying to change color with data on the total break time using conditional formatting.
What would be a correct formula for saying "If time is equal to or greater than 32 minutes, then change color to red"
 
Upvote 0
formula
what column are we at now
Assuming W as the image

select W range or column if you select a range - W4:W18
then the formula needs to start at W4
if you select the entire column then W1

Assuming Range selected is W4:W18

use as a formula
=W4>=TIMEVALUE("00:32:00")
Fill Red

added updated sample

Start-stop times -3.xlsx
ABCDEFGHIJKLMNOPQRSTUVWX
2startendstartendstartendstartendTIMEHelperValidation
3
4Name 10:000TRUE
5Name 20:300TRUE
6Name 30:320TRUE
7Name 40:350TRUE
8Name 50:150TRUE
9Name 61:200TRUE
10Name 70:310TRUE
11Name 80TRUE
12Name 90TRUE
13Name 100TRUE
14Name 110TRUE
15Name 120TRUE
16Name 130TRUE
17Name 140TRUE
18Name 150TRUE
19
20Currently on Break: 0
Sheet1
Cell Formulas
RangeFormula
W4:W18W4=IF(OR(AND(C4<>"",E4=""),AND(H4<>"",J4=""),AND(M4<>"",O4="")),1,0)
X4:X18X4=(COUNTIFS($C4:$C4,"<>"&"",$E4:$E4,"")+COUNTIFS($H4:$H4,"<>"&"",$J4:$J4,"")+COUNTIFS($M4:$M4,"<>"&"",$O4:$O4,"") +COUNTIFS($R4:$R4,"<>"&"",$T4:$T4,""))<2
C20C20="Currently on Break: " & SUM(W4:W18)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
V4:V18Expression=V4>=TIMEVALUE("00:32:00")textNO
C20Expression=OR(C20="Currently on Break: "&3,C20="Currently on Break: "&4)textNO
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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