This should do the trick. All the colour shaded areas of the overtime bucket are deleted & repopulated with the data from the overtime list each time the macro is run. I haven't included the total hours or the paid hours columns.
Thanks for the rep
Option Explicit
Sub Overtimers()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
Dim Ws4 As Worksheet
Dim DupRange As Range ' Range of duplicates
Dim rCell As Range ' Looping cell
Dim i As Long ' Counter
Dim strIN As String ' The word "IN"
i = 117
strIN = "IN"
Set Ws4 = ThisWorkbook.Sheets(1)
' The range where Overtime workers appear
Set DupRange = Ws4.Range(Ws4.Cells(95, 10), Ws4.Cells(114, 10))
' Delete contents from Overtime Bucket
With Ws4
.Range(Ws4.Cells(117, 8), Ws4.Cells(131, 8)).ClearContents
.Range(Ws4.Cells(117, 10), Ws4.Cells(131, 12)).ClearContents
.Range(Ws4.Cells(117, 16), Ws4.Cells(131, 19)).ClearContents
End With
' Loop through overtime worker range
For Each rCell In DupRange
' If the adjacent cell in col G has the value IN, overtime has been committed
If UCase(rCell.Offset(, -3).Value) = strIN Then
With Ws4.Cells(i, 10) ' Top Cell Of Overtime Bucket
.Value = rCell.Value ' Name
.Offset(, -2).Value = rCell.Offset(, -2).Value ' Program
.Offset(, 1).Value = rCell.Offset(, 1).Value ' Schedule
.Offset(, 6).Value = rCell.Offset(, 2).Value ' Start Time
.Offset(, 7).Value = rCell.Offset(, 3).Value ' End Time
.Offset(, 8).Value = rCell.Offset(, 8).Value ' OT Break
.Offset(, 9).Value = rCell.Offset(, 9).Value ' OT Lunch
End With
i = i + 1 ' Counter Up 1
End If
Next rCell
With Application
.DisplayAlerts = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
Exit Sub
End Sub
Bookmarks