98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Checking if time is greater or less than a specific time
Checking if time is greater or less than a specific time
Resolved · Low Priority · Version 2010
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
Thu 21 Dec 2017: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Adding a comment to a formula1. At the end of the formula, add a + (plus) sign.
|