Hello Everyone,
Thanks again for the above, I was able to get it to work. Now I have another sub project.
I have about 3000 rows of data which consists of phone numbers and the date they called. Column A has phone numbers and Column B has the date they called. Phone numbers are repeated in column A and I have sorted it them. I have to choose if the phone number is the same, find the recent date that they called and highlight it. Sometimes people have called multiple times on the same date. Below is my code and I am getting run time error. The code should go only to 3000 rows however it is going through the entire excel.
Code:
Sub greaterdate()
Sheets("Sheet1").Select
Dim a As Long
Dim b As Long
Dim x As Date
Dim y As Date
count = 2
a = Cells(count, 1).Value
b = Cells(count + 1, 1).Value
x = Cells(count, 2).Value
y = Cells(count + 1, 2).Value
Do While a = b
If x < y Then
Cells(count, 2).Interior.Color = RGB(255, 0, 0)
ElseIf x = y Then
Cells(count + 1, 2).Interior.Color = RGB(255, 0, 0)
ElseIf x > y Then
Cells(count + 1, 2).Interior.Color = RGB(255, 0, 0)
End If
count = count + 2
Loop
End Sub
Bookmarks