Hello S-Hart,
It seems to me you want to format all the time cells on the report. You have 2 distinct formats "hh:mm:ss: for "In", "Out", and "Stop" while "Dwell" is "hh:mm".
This is easily accomplished by leaving the spaces in the cells. The code below will correctly format only cells with time values. This macro has been added to the attached workbook.
Sub FormatTimes()
Dim Cell As Range
Dim Rng As Range
Dim Wks As Worksheet
Dim Word As String
Set Wks = Worksheets("Sheet1")
Set Rng = Wks.Range("A1").CurrentRegion
Set Rng = Intersect(Rng, Rng.Offset(1, 6))
For Each Cell In Rng
Word = Left(Cell, InStr(1, Cell, " "))
Select Case Word
Case Is = "In ", "Out ", "Stop "
Cell.NumberFormat = "hh:mm:ss"
Case Is = "Dwell "
Cell.NumberFormat = "hh:mm"
End Select
Next Cell
End Sub
Bookmarks