I'm very new to excel VBA and I can't figure out how to get this to work. I have a column (column K), with a header in K1. I get this spreadsheet every day and it has a different number of rows. Column K has numbers from 0-100. I need to highlight certain rows certain colors depending on the value in column K. This is what I have so far, but it just goes all the way down and makes every column red font. I need it to loop through k2 to the last K cell with a value and change the font color of each row.
Columns("K").Select
Dim firstCell As Integer
Dim finalCell As Integer
firstCell = Range("K2")
finalCell = Range("K65536").End(xlUp).Row
For i = firstCell To finalCell
If i > 5 Then
Rows(i).Select
With Selection.Font
.Color = RGB(255, 0, 0)
End With
ElseIf i = 4 Then
Rows(i).Select
With Selection.Font
.Color = RGB(226, 107, 10)
End With
ElseIf i = 3 Then
Rows(i).Select
With Selection.Font
.Color = RGB(0, 176, 80)
End With
ElseIf i = 2 Then
Rows(i).Select
With Selection.Font
.Color = RGB(0, 112, 192)
End With
ElseIf i = 1 Then
Rows(i).Select
With Selection.Font
.Color = RGB(112, 48, 160)
End With
End If
Next i