Hello,
I am trying add to this code I started building and stuck on adding VBA to extract hours from 2 times (columns). The problem is I need to get these hrs, but then -.50. So for example if the hours extracted from 2 times is 7hs I want the result to be 6.5hrs (hence the -.50).
Here is the attachment and what is highlighted in yellow is where I would like the hours calculate (Columns C:I).
Any help would be MUCH APPRECIATED!
Here is the code.
Sub Add_Breaks()
Dim ws As Worksheet
Dim Cell As Range
Application.ScreenUpdating = False
'For Each ws In ThisWorkbook.Sheets
'Find 6.5 hrs mark
For Each Cell In ActiveSheet.Range("F:F,L:L")
If Not IsEmpty(Cell.Offset(, -1).Value) And IsDate(Cell.Offset(, -1).Text) Then
Cell.Value = Cell.Offset(, -2).Value + TimeSerial(5, 59, 0)
Cell.NumberFormat = "hh:mm"
End If
Next Cell
Columns("F:F").Select
Selection.NumberFormat = "[$-409]h:mm AM/PM;@"
Columns("L:L").Select
Selection.NumberFormat = "[$-409]h:mm AM/PM;@"
Cells.Select
Selection.Replace What:="blank", Replacement:="Min Break", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Columns("C:C").Select
Selection.NumberFormat = "[$-409]h:mm AM/PM;@"
Columns("I:I").Select
Selection.NumberFormat = "[$-409]h:mm AM/PM;@"
Cells.Select
Selection.Replace What:="Meal", Replacement:="Sched Hrs", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
'Highlight Blue
With Range("F:F, L:L")
.Font.Color = vbBlue
.Font.Bold = True
End With
'Colums Autofit
Columns("F:F").EntireColumn.AutoFit
Columns("L:L").EntireColumn.AutoFit
'Fix page break
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
ActiveSheet.PageSetup.PrintArea = "$A$1:$L$54"
ActiveWindow.View = xlNormalView
Range("A2").Select
Application.ScreenUpdating = True
End Sub
Bookmarks