Macro to Look for Differences in Time

FrenchCelt

Board Regular
Joined
May 22, 2018
Messages
99
Hello,

I'm building a macro that identifies time errors to be fixed off a report that includes employee clock in/clock out times. The only values that matter are the actual clock out times vs. system clock out times. Specifically, if an employee physically clocked out at one time, but the system shows a later clock out time, it means I need to go fix the problem that caused this discrepancy. I've done all the necessary formatting in my VBA code to make the data useful for sorting, but I can't figure out a way to make the macro compare the time values in one column (Col C) with the time values in the other column (Col E). If they are identical, no problem, but if they are different, I need these to appear either using some kind of conditional formatting that identifies the ones that are different and then filters for that formatting, or conditionally formats the ones that are identical and then sorts them out, only leaving behind the ones that are different. Or maybe one of you knows of another way to achieve this end result without conditional formatting.

Any help would be appreciated.
 

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,415
Office Version
  1. 2013
Platform
  1. Windows
Code:
Dim c As Range, sh As Worksheet
Set sh = ActiveSheet
For Each c In sh.Range("C2", sh.Cells(Rows.Count, 3).End(xlUp))
    If c.Value <> c.Offset(, 2).Value Then c.EntireRow.Interior.Color = vbYellow
Next
 

FrenchCelt

Board Regular
Joined
May 22, 2018
Messages
99
Code:
Dim c As Range, sh As Worksheet
Set sh = ActiveSheet
For Each c In sh.Range("C2", sh.Cells(Rows.Count, 3).End(xlUp))
    If c.Value <> c.Offset(, 2).Value Then c.EntireRow.Interior.Color = vbYellow
Next

Brilliant! Thank you so much! :)
 

Watch MrExcel Video

Forum statistics

Threads
1,108,625
Messages
5,523,970
Members
409,548
Latest member
Buildingbysea

This Week's Hot Topics

Top