So the goal here Is that I have a sheet ranging from A:J with headers on row 1. I am trying to evaluate columns F & G (variable ranges) They are date ranges but I would like this to apply for all values not just dates. The if conditions I am testing for include
This should be accounted for that F2 & G2 are compared then it goes to F3 & G3... and so on through a variable range (Last row)
If F is >= G the the boxes should turn green
If F is < G then the boxes should turn yellow
below is the code I have got so far it runs with no errors but nothing happens when I run it.
Sub ColorEvaluation()
Dim Ws1 as Worksheet
Dim lr as Long
DIm r as Long
Set Ws1 = thisworkbook.Worksheets("Sheet 1")
lr = Ws1.Cells(Ws1.Rows.Count, "A").End(xlUp).Row
for r = 2 to lr
if Ws1.Range("F" & lr) >= Ws1.Range("G" & lr) _
then
Ws1.Range("F" & lr).interior.colorindex = 4
Ws1.Range("G" & lr).interior.colorindex = 4
Elseif Ws1.Range("F" & lr) < Ws1.Range("G" & lr) _
then
Ws1.Range("F" & lr).interior.colorindex = 6
Ws1.Range("G" & lr).interior.colorindex = 6
End if
Next r
End Sub
This should be accounted for that F2 & G2 are compared then it goes to F3 & G3... and so on through a variable range (Last row)
If F is >= G the the boxes should turn green
If F is < G then the boxes should turn yellow
below is the code I have got so far it runs with no errors but nothing happens when I run it.
Sub ColorEvaluation()
Dim Ws1 as Worksheet
Dim lr as Long
DIm r as Long
Set Ws1 = thisworkbook.Worksheets("Sheet 1")
lr = Ws1.Cells(Ws1.Rows.Count, "A").End(xlUp).Row
for r = 2 to lr
if Ws1.Range("F" & lr) >= Ws1.Range("G" & lr) _
then
Ws1.Range("F" & lr).interior.colorindex = 4
Ws1.Range("G" & lr).interior.colorindex = 4
Elseif Ws1.Range("F" & lr) < Ws1.Range("G" & lr) _
then
Ws1.Range("F" & lr).interior.colorindex = 6
Ws1.Range("G" & lr).interior.colorindex = 6
End if
Next r
End Sub