Sample Worksheet.xlsxSample Worksheet.xlsxSample workbook attached.
I am currently using this code, thanks to the help of this board to check against scheduling the same employee in a shift. I have tried in vain to utilize this template to further code the rest of the workbook.
'Private Sub Worksheet_Change(ByVal Target As Range)
check for duplicate shifts (Friday)
Dim myrange As Range
Set myrange = Range("L8:L187")
If Not Intersect(Target, myrange) Is Nothing Then
Application.EnableEvents = False
If WorksheetFunction.CountIf(myrange, Target) > 1 Then
MsgBox "This employee has already been scheduled during the matinee shift.", vbExclamation + vbOKOnly, "Duplicate Shift"
ActiveCell.Select
Selection.ClearContents
End If
GoTo exit_sub
End If
Set myrange = Range("AB8:AH187")
If Not Intersect(Target, myrange) Is Nothing Then
Application.EnableEvents = False
If WorksheetFunction.CountIf(myrange, Target) > 1 Then
MsgBox "This employee has already been scheduled during the evening shift.", vbExclamation + vbOKOnly, "Duplicate Shift"
ActiveCell.Select
Selection.ClearContents
End If
End If
exit_sub:
Application.EnableEvents = True
End Sub
Explanations of what I am after included in the very basic attached workbook.
Any help is greatly appreciated.
Bookmarks