Natasha has attended:
Excel Advanced course
Excel VBA Introduction course
Excel Advanced - Formulas & Functions course
Excel VBA Intermediate course
Excel Dashboards for Business Intelligence course
Excel Forecasting and Data Analysis course
Excel VBA Advanced course
Checking if time is greater or less than a specific time
Hello,
Please could you tell me why the following statement does not work? I have tried using "ActiveCell.Offset(0, 3).Value > 0.5" instead of stating the actual time as I would like everything past midday but this does not work either.
Sub WedsPM()
Range("I2").Select
Do Until ActiveCell = ""
If ActiveCell.Value = "Wednesday" And (ActiveCell.Offset(0, 3).Value > TimeValue("12:00:00") Or ActiveCell.Offset(0, 2).Value > TimeValue("12:00:00")) Then
ActiveCell.EntireRow.Interior.ColorIndex = 43
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
RE: Checking if time is greater or less than a specific time
Hi Natasha,
Thank you for the forum question.
The code works fine. You may have a problem with the time you are testing.
If Excel does not recognise your time as time the code will not work.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector