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 » Using a Difference rather than Less than or More than
Using a Difference rather than Less than or More than
Resolved · High Priority · Version 2013
Sean has attended:
Excel VBA Introduction course
Excel VBA Intermediate course
Using a Difference rather than Less than or More than
I'm trying to create a Code to insert a row whenever the following applies:
active cell is more than 1 second difference to activecell.offset(-1,0)
then i'll put it into a do loop to work its way down the list.
Anyone know how to use differences?
RE: Using a Difference rather than Less than or More than
Hi Sean.
Thank you for the forum question.
Please have a look at the code below.
Sub Test()
Range("b2").Select
Do Until ActiveCell = ""
If TimeSerial(Hour(ActiveCell), Minute(ActiveCell), Second(ActiveCell)) <> _
TimeSerial(Hour(ActiveCell.Offset(-1, 0)), Minute(ActiveCell.Offset(-1, 0)), Second(ActiveCell.Offset(-1, 0)) - 1) _
And TimeSerial(Hour(ActiveCell), Minute(ActiveCell), Second(ActiveCell)) <> _
TimeSerial(Hour(ActiveCell.Offset(-1, 0)), Minute(ActiveCell.Offset(-1, 0)), Second(ActiveCell.Offset(-1, 0)) + 1) _
And TimeSerial(Hour(ActiveCell), Minute(ActiveCell), Second(ActiveCell)) <> _
TimeSerial(Hour(ActiveCell.Offset(-1, 0)), Minute(ActiveCell.Offset(-1, 0)), Second(ActiveCell.Offset(-1, 0))) Then
ActiveCell.Font.Color = vbRed
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub
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
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:Create a unique items table from a duplicating table1. Ensure that your list has column headings |