Macro para poner formatos condicionales rojo, amarillo, verde y en blanco para celdas vacías.
Este código les creará formatos condicionales que saldrán en rojo para valores menores al 50%, amarillo para mayores o iguales al 50% y menores al 80%, y verde para valores iguales o mayores a 80%. Si la celda está en blanco, no tendrá formato.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
Sub Tres_colores_R50_A80_V100() ' Asigna un formato condicional de tres colores. ' Rojo < 50%, Amarillo >=50% y <80%, Verde >= 80%. Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _ Formula1:="=1" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Font .Color = -16383844 .TintAndShade = 0 End With With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 13551615 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual, _ Formula1:="=0.5" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Font .Color = -16751204 .TintAndShade = 0 End With With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 10284031 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual, _ Formula1:="=0.8" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority With Selection.FormatConditions(1).Font .Color = -16752384 .TintAndShade = 0 End With With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .Color = 13561798 .TintAndShade = 0 End With Selection.FormatConditions(1).StopIfTrue = False Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _ Formula1:="=""""" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority Selection.FormatConditions(1).StopIfTrue = True End Sub |
Deja una respuesta