Help! Please!
I have 3 sheets but only working through Sheet2 and Sheet3 for this code. The Sheet3 contains raw data that I want to validate against Sheet2, which has valid values. So basically go row by row through Sheet3 and compare the value from the identified cell against all data in the specified column in Sheet2. When a match is found I want the cells offset from the matching value in Sheet3 and Sheet2 set as the PEDATE and CEDate. I then want to compare the dates and if PEDate is greater than the CEDate I want the individual cell highlighted on Sheet3.
I am not getting an error but also not getting my desired result. Not sure if I am close or way off. Any help would be greatly appreciated.
I have 3 sheets but only working through Sheet2 and Sheet3 for this code. The Sheet3 contains raw data that I want to validate against Sheet2, which has valid values. So basically go row by row through Sheet3 and compare the value from the identified cell against all data in the specified column in Sheet2. When a match is found I want the cells offset from the matching value in Sheet3 and Sheet2 set as the PEDATE and CEDate. I then want to compare the dates and if PEDate is greater than the CEDate I want the individual cell highlighted on Sheet3.
I am not getting an error but also not getting my desired result. Not sure if I am close or way off. Any help would be greatly appreciated.
Code:
Sub Coverage_Effective_Date()
Dim U As Long
Dim C As Long
Dim PEDate As Date
Dim CEDate As Date
With Sheet3
Range("U:U").Font.ColorIndex = 1
For U = 2 To Sheet3.Cells(.Rows.Count, "A").End(xlUp).Row
For C = 3 To Sheet2.Cells(.Rows.Count, "A").End(xlUp).Row
If Not IsError(Application.Match(Sheet3.Cells(U, "W"), Sheet2.Cells(C, "B"), 0)) Then
PEDate = .Cells(C, "C")
CEDate = .Cells(U, "U")
End If
If PEDate > CEDate Then
Sheet3.Cells(U, "U").Font.ColorIndex = 3
End If
Next C
Next U
End With
End Sub