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, but why would 1 employee fill in three sections and be out for all of them
can they be on lunch and also in 2 15min breaks
So they can only be out once - regardless of how the template is filled in
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Quickest way is with a helper column
But i will look into without the need for a helper column
Book2
ABCDEFGHIJKLMNOPQ
2startendstartendstartendHelper
3Name 111:000:0014:000:000
4Name 213:0012:000
5Name 314:0014:001
6Name 411:001
7Name 50
8Name 611:0012:0013:001
9Name 70
10Name 80
11Name 90
12Name 100
13Name 110
14Name 120
15Name 130
16Name 140
17Name 150
18
19Currently on Break: 3
Sheet1
Cell Formulas
RangeFormula
Q3:Q17Q3=IF(OR(AND(C3<>"",E3=""),AND(H3<>"",J3=""),AND(M3<>"",O3="")),1,0)
C19C19="Currently on Break: " & SUM(Q3:Q17)



 
Upvote 0
You're right. I don't assume someone could be so careless to go on a 2nd break, without setting the return time on their first. But in case someone made this mistake, it would prevent a 3rd agent from going on break as they'd think 3 agents are already out, when in fact the second employee forgot to set the return times for himself. Since we work from home it's harder to check where an agent actually is. If a solution can be found easily, good. If not - this will have to do too.
 
Upvote 0
Is the helper column OK

IF Not then you could add data validation to the sheet , so that an employee cannot add another starttime

Book2
ABCDEFGHIJKLMNOPQR
2startendstartendstartendHelperValidation
3Name 10:000TRUE
4Name 212:001TRUE
5Name 30TRUE
6Name 40TRUE
7Name 50TRUE
8Name 60TRUE
9Name 70TRUE
10Name 80TRUE
11Name 90TRUE
12Name 100TRUE
13Name 110TRUE
14Name 120TRUE
15Name 130TRUE
16Name 140TRUE
17Name 150TRUE
18
19Currently on Break: 1
Sheet1
Cell Formulas
RangeFormula
Q3:Q17Q3=IF(OR(AND(C3<>"",E3=""),AND(H3<>"",J3=""),AND(M3<>"",O3="")),1,0)
R3:R17R3=(COUNTIFS($C3:$C3,"<>"&"",$E3:$E3,"")+COUNTIFS($H3:$H3,"<>"&"",$J3:$J3,"")+COUNTIFS($M3:$M3,"<>"&"",$O3:$O3,""))<2
C19C19="Currently on Break: " & SUM(Q3:Q17)
Cells with Data Validation
CellAllowCriteria
C3:O17Custom=(COUNTIFS($C3:$C3,"<>"&"",$E3:$E3,"")+COUNTIFS($H3:$H3,"<>"&"",$J3:$J3,"")+COUNTIFS($M3:$M3,"<>"&"",$O3:$O3,""))<2
 
Upvote 0
I'm working my head around how this works, but I did get 1 idea, not sure how correct it is.
Is it possible to make it so that an employee cannot add another start time, if there already is a start time without a return time? Is this what the Validation does, and can we have the validation be active, but hidden?

On another note, I was unable to change colors with value. Did I do it right? I tried both "A20 = 0" and "A20 = CURRENTLY ON BREAK: 0".
I guess I misunderstood how to do it.
 

Attachments

  • Screenshot_54.png
    Screenshot_54.png
    78.9 KB · Views: 7
Upvote 0
Is it possible to make it so that an employee cannot add another start time, if there already is a start time without a return time? Is this what the Validation does, and can we have the validation be active, but hidden?

YES it is hidden, i just added the column to show the formula for info

On another note, I was unable to change colors with value. Did I do it right? I tried both "A20 = 0" and "A20 = CURRENTLY ON BREAK: 0".
I guess I misunderstood how to do it.


NO
We need to change the conditional formatting
What cell is it actually in A20 ??

Then USE
=C19="Currently on Break: "&1
change the &1
for
&2
&3
If you want to do a greater than
I'm having to do an OR
=OR(C19="Currently on Break: "&3,C19="Currently on Break: "&4)

I have added spaces on mine - so need to match any number of spaces you may have added

 
Upvote 0
I assume that it is A20.

When I select the cell that has the formula ="Currently on Break: " & (COUNTIFS(C:C,"<>"&"",E:E,"") + COUNTIFS(H:H,"<>"&"",J:J,"") + COUNTIFS(M:M,"<>"&"",O:O,"") + COUNTIFS(R:R,"<>"&"",T:T,""))

The top left corner before the formula, above name, shows A20.

Also I've just tried =C19="Currently on Break: "&1 , and it didn't work as well.

I can't identify what I'm doing wrong.
 

Attachments

  • Screenshot_55.png
    Screenshot_55.png
    48.6 KB · Views: 8
Upvote 0
"the agents can double-click on a cell for time input under Start time"

Have you condidered keeping count via your Double click routine?

Double click a Start cell increases a NumberOnBreak variable by 1.
Double click on a End cell decreases that variable?

The value of the NumberOnBreak variable would limit what the routine would do.
e.g if NumberOnBreak < 3 then a double click on a Start cell will put in a time stamp in the cell and incriment NumberOnBreak
If NumberOnBreak >= 3 then d-c on a Start cell will bring up a "Too Many On Break" message.
 
Last edited:
Upvote 0
so it is A20 that you need to add the formula
"Currently on Break: " & (COUNTIFS(C4:C18,"<>"&"",E4:E18,"") + COUNTIFS(H4:H18,"<>"&"",J:J,"") + COUNTIFS(M4:M18,"<>"&"",O4:O18,"") + COUNTIFS(R4:R18,"<>"&"",T4:T18,""))

I did say as the merge cell in the columns change to the range of cells
 
Upvote 0
Hello Mike,

I have not considered that. I never dealt with Excel code or formulas, so I didn't even think of that. I'm also not sure it would work. My manager just now told me this file will be upload on Microsoft Teams in a files section, and apparently macros don't work that way. The workaround is "CTRL + SHIFT + :" for time input, I've just checked and most of the functionality we've added still works, with the exception of double-click for time input, and lock cell after cell entry. Any solution to show Agents currently on break (without showing 2 breaks as 2 agents), that works on an online shared worksheet is welcomed. I am yet to try Wayne's solution and see how it goes.

Wayne, I did add that formula to the A20 cell, in the screenshot I attached previously, you can see at the top it shows the formula. I'm still not sure what I'm doing wrong.
 
Upvote 0

Forum statistics

Threads
1,216,102
Messages
6,128,851
Members
449,471
Latest member
lachbee

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