Macro to Look for Differences in Time

FrenchCelt

Board Regular
Joined
May 22, 2018
Messages
210
Office Version
  1. 365
Platform
  1. Windows
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.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
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! :)
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,428
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top