J
Josh O.
I have the following VBA to enter, copy and paste conditional formats. But
it gets stuck at the first ".Add (xlExpression,...)" line.
This is what I want it to do:
If I2 is less than or equal to 60 from today and greater than 30 days from
today and A2 is not blank then highlight A2:J2 color 34...
Or
If I2 is less than or equal to 30 from today and greater than today and A2
is not blank then highlight A2:J2 color 36...
Or
If I2 is less today and A2 is not blank then highlight A2:J2 color 38 and
change font to white...
then copy formula down to last row.
Here is the current code:
With Range("a2:j2").FormatConditions
.Delete
.Add(xlExpression, ,
"=and($i2<=(today()+60),$i2>(today()+30),$a2<>"")").Interior.ColorIndex = 34
.Add(xlExpression, ,
"=and($i2<=(today()+30),$i2>(today()),$a2<>"")").Interior.ColorIndex = 36
.Add(xlExpression, ,
"=and($i4<today(),$a2<>"")").Interior.ColorIndex = 38
End With
With Range("a2:j2")
.Copy
Range("a2:j" & Range("j65536").End(xlUp).Row).PasteSpecial
xlPasteFormats
End With
it gets stuck at the first ".Add (xlExpression,...)" line.
This is what I want it to do:
If I2 is less than or equal to 60 from today and greater than 30 days from
today and A2 is not blank then highlight A2:J2 color 34...
Or
If I2 is less than or equal to 30 from today and greater than today and A2
is not blank then highlight A2:J2 color 36...
Or
If I2 is less today and A2 is not blank then highlight A2:J2 color 38 and
change font to white...
then copy formula down to last row.
Here is the current code:
With Range("a2:j2").FormatConditions
.Delete
.Add(xlExpression, ,
"=and($i2<=(today()+60),$i2>(today()+30),$a2<>"")").Interior.ColorIndex = 34
.Add(xlExpression, ,
"=and($i2<=(today()+30),$i2>(today()),$a2<>"")").Interior.ColorIndex = 36
.Add(xlExpression, ,
"=and($i4<today(),$a2<>"")").Interior.ColorIndex = 38
End With
With Range("a2:j2")
.Copy
Range("a2:j" & Range("j65536").End(xlUp).Row).PasteSpecial
xlPasteFormats
End With