Bemerkungen
Sie können nicht mehr als drei bedingte Formate für einen Bereich definieren. Verwenden Sie die Modify-Methode, um ein vorhandenes bedingtes Format zu ändern, oder löschen Sie ein vorhandenes Format mit der Delete-Methode, bevor Sie ein neues hinzufügen.
Syntax:
FormatConditions.Add(Type, Operator, Formula1, Formula2)
Parameter:
| Name | Erforderlich / optional | Datentyp |
|---|
| Art | Erforderlich | XlFormatConditionType |
| Operator | Wahlweise | Variante |
| Formel 1 | Wahlweise | Variante |
| Formula2 | Wahlweise | Variante |
| Name | Beschreibung |
|---|
| xlAboveAverageCondition | Überdurchschnittlicher Zustand |
| xlBlanksCondition | Leere Bedingung |
| xlCellValue | Zellenwert |
| xlColorScale | Farbskala |
| xlDatabar | Databar |
| xlErrorsCondition | Fehlerbedingung |
| xlExpression | Ausdruck |
| XlIconSet | Icon-Set |
| xlNoBlanksCondition | Keine Leerzeichen |
| xlNoErrorsCondition | Keine Fehlerbedingung |
| xlTextString | Textzeichenfolge |
| xlTimePeriod | Zeitperiode |
| xlTop10 | Top 10 Werte |
| xlUniqueValues | Einzigartige Werte |
With Range("A1").FormatConditions.Add(xlCellValue, xlGreater, "=100")
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
Betreiber:
| Name |
|---|
| xlBetween |
| xlEqual |
| xlGreater |
| xlGreaterEqual |
| xlLess |
| xlLessEqual |
| xlNotBetween |
| xlNotEqual |
Wenn Typ xlExpression ist, wird das Operator-Argument ignoriert.
Die Formatierung nach Text enthält:
With Range("a1:a10").FormatConditions.Add(xlTextString, TextOperator:=xlContains, String:="egg")
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
Betreiber:
| Name | Beschreibung |
|---|
| xlBeginsWith | Beginnt mit einem angegebenen Wert. |
| xlContains | Enthält einen angegebenen Wert. |
| xlDoesNotContain | Enthält nicht den angegebenen Wert. |
| xlEndsWith | Ende mit dem angegebenen Wert |
With Range("a1:a10").FormatConditions.Add(xlTimePeriod, DateOperator:=xlToday)
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
Betreiber:
| Name |
|---|
| Gestern |
| xl Morgen |
| xlLast7Days |
| xlLastWeek |
| xlThisWeek |
| xlNextWeek |
| xlLastMonth |
| xlThisMonth |
| xlNextMonth |
Range("A1:A10").FormatConditions.Delete
Cells.FormatConditions.Delete
Doppelte Werte hervorheben
With Range("E1:E100").FormatConditions.AddUniqueValues
.DupeUnique = xlDuplicate
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
Einzigartige Werte hervorheben
With Range("E1:E100").FormatConditions.AddUniqueValues
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
Top 5-Werte hervorheben
With Range("E1:E100").FormatConditions.AddTop10
.TopBottom = xlTop10Top
.Rank = 5
.Percent = False
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
With Range("E1:E100").FormatConditions.AddAboveAverage
.AboveBelow = xlAboveAverage
With .Font
.Bold = True
.ColorIndex = 3
End With
End With
Betreiber:
| Name | Beschreibung |
|---|
| XlAboveAverage | Überdurchschnittlich |
| XlAboveStdDev | Oberhalb der Standardabweichung |
| XlBelowAverage | Unterdurchschnittlich |
| XlBelowStdDev | Unter Standardabweichung |
| XlEqualAboveAverage | Gleich überdurchschnittlich |
| XlEqualBelowAverage | Gleich unterdurchschnittlich |
Range("a1:a10").FormatConditions.AddIconSetCondition
With Selection.FormatConditions(1)
.ReverseOrder = False
.ShowIconOnly = False
.IconSet = ActiveWorkbook.IconSets(xl3Arrows)
End With
With Selection.FormatConditions(1).IconCriteria(2)
.Type = xlConditionValuePercent
.Value = 33
.Operator = 7
End With
With Selection.FormatConditions(1).IconCriteria(3)
.Type = xlConditionValuePercent
.Value = 67
.Operator = 7
End With
IconSet:
| Name |
|---|
| xl3-pfeile |
| xl3ArrowsGray |
| xl3Flags |
| xl3Signs |
| xl3Stars |
| xl3Symbole |
| xl3Symbols2 |
| xl3TrafficLights1 |
| xl3TrafficLights2 |
| xl3Dreieck |
| xl4-pfeile |
| xl4ArrowsGray |
| xl4CRV |
| xl4RedToBlack |
| xl4TrafficLights |
| xl5Pfeile |
| xl5ArrowsGray |
| xl5Boxen |
| xl5CRV |
| xl5Quarters |
Art:
| Name |
|---|
| xlConditionValuePercent |
| xlConditionValueNumber |
| xlConditionValuePercentile |
| xlConditionValueFormula |
Operator:
| Name | Wert |
|---|
| xlGreater | 5 |
| xlGreaterEqual | 7 |
Wert:
Gibt den Schwellenwert für ein Symbol in einem bedingten Format zurück oder legt diesen fest.