I’m looking for a way to highlight a range of cells in a row based on the time that is within the cell. And I’d like to have a way to input the time and have it highlight anything that is greater than the time entered. The cell contains the date-time in the m/d/yyy hh:mm:ss AM/PM format. Example: 3/27/2009 7:00:00 PM
Here is what I’ve tried with no success (it doesn’t crash…just doesn’t work):
Sub Time()
Dim MyInput
MyInput = InputBox(“Enter time”)
For Each cell In ActiveSheet.Range(“O2:O450”).Cells.SpecialCells(xlCellTypeConstants)
If cell.Value > MyInput Then
Range(“A” & cell.Row & “:X” & cell.Row).Interior.Color = RGB(146, 208, 80)
End If
Next cell
End Sub
I can get it to highlight based on an exact time by using Like.
If cell.Value Like “*” & MyInput & “*” Then
Is there a way to do what I’m wanting to do?
I’m using Excel 2007.
Thanks in advance for the pointers.