
To get the # of months between 2 dates you can use this: =IF(TODAY() > $A2, -DATEDIF($A2, TODAY(),"m"), DATEDIF(TODAY(), $A2,"m"))
where $A2
is just a cell reference. This would return the # of months between the given cell's date and today. DATEDIF
doesn't like negative values so the IF
is required. Given this formula you can then select the correct icon set using conditional formatting.
If you want to continue doing this in a script then replace the simple select case
statement with select case <formula>
. You then get back the # of months and can use the simple case statement.
Select Case IF(TODAY() > c14, -DATEDIF(c14, TODAY(),"m"), DATEDIF(TODAY(), c14,"m"))
Case 1: Shapes("Green1").Visible = msoTrue
Case 2: Shapes("Yellow1").Visible = msoTrue
Case 3: Shapes("Rojo1").Visible = msoTrue
End Select
If you have that value already calculated in your spreadsheet somewhere then you can use the conditional formatting UI to do the same thing. But if you don't then it becomes harder because icon sets and custom formulas don't work together so you end up having to use multiple rules.