I am trying to run an If Then in column J that will tell me weather or not to color a cell in column G with a sub If Then that will change the color of the cell.
I must be missing something because the macro runs without an issue but I'm not getting the desired results .... any help would be appreciated.
Private Sub Worksheet_Activate()
Dim C As Variant
Dim CI As Integer
Dim Col As Variant
Dim FirstRow As Long
Dim LastRow As Long
Dim Rng As Range
Dim Wks As Worksheet
Col = "J"
FirstRow = 2
Set Wks = Worksheets("Pauline")
LastRow = Wks.Cells(Rows.Count, Col).End(xlUp).Row
LastRow = IIf(LastRow < FirstRow, FirstRow, LastRow)
Set Rng = Wks.Range(Cells(FirstRow, Col), Cells(LastRow, Col))
For Each C In Rng
If (Range(Cells(FirstRow, Col), Cells(LastRow, Col)) = "Yes") Then
Col = "G"
FirstRow = 2
Set Wks = Worksheets("Pauline")
LastRow = Wks.Cells(Rows.Count, Col).End(xlUp).Row
LastRow = IIf(LastRow < FirstRow, FirstRow, LastRow)
Set Rng = Wks.Range(Cells(FirstRow, Col), Cells(LastRow, Col))
If IsDate(C) Then
Select Case Int(Now()) - C
Case Is > 90
CI = 3 'Red
Case Is > 75
CI = 6 'Yellow
Case Is > 60
CI = 4 'Green
Case Else
CI = xlColorIndexNone
End Select
C.Interior.ColorIndex = CI
End If
End If
Next C
Bookmarks