Skip to content

Instantly share code, notes, and snippets.

@TABETA
Created October 10, 2016 08:33
Show Gist options
  • Save TABETA/dac49b55f7a8252e571988b7fd3ec713 to your computer and use it in GitHub Desktop.
Save TABETA/dac49b55f7a8252e571988b7fd3ec713 to your computer and use it in GitHub Desktop.
Function truncDate(t As Date) As Date
truncDate = TimeSerial(Hour(t), Minute(t), 0)
End Function
Function findTime(r As Long, c As Long) As Long
findTime = Application.WorksheetFunction.Match(CDbl(truncDate(Cells(r, c))), Range("2:2"), 1)
End Function
Sub t()
Dim cs As Long
Dim ce As Long
Dim c As Long
Dim r As Long
Dim MaxRow As Long
MaxRow = Cells(3, 1).End(xlDown).Row
For r = 3 To MaxRow
cs = findTime(r, 1)
ce = findTime(r, 2)
For c = cs To ce
Cells(r, c).Value = "o"
Next
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment