AW: Bedingte Formatierung
05.10.2022 21:17:00
Yal
Hallo Richi,
Es mag eventuell eine Unterschied zwischen Excel 2013 (deins) und Excel 2016 (meins) geben, aber da wäre ich überrascht.
Ich habe folgende Code aufgezeichnet (ausser RGB: nachgebessert)
Sub Makro1()
' Makro1 Makro
Range("B6:B14").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=UND($A3=""t"";$B3=""A0100"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = RGB(217, 217, 217)
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Lese den Code laut und "auf Deutsch", als ob Du es für jemand anderes lesen würdest. Dann wirst Du merken, dass es darin viel mehr "nachvollziehbares" gibt, als was man zuerst denkt:
Es wird den Bereich B6:B14 markiert
Auf dieser Markierung wird an der Auflistung der FormatCondition (FormatConditions) eine neue Bedingung (FormatCondition) vom Typ Ausdruck und mit Formel ...
Wenn Du ein VBA-Wort nicht kennst oder verstehst, platziere den Cursor drauf und drücke Strg+F1. So kommst Du auf die Online-Hilfe dieses Begriffes. Die Erklärung ist auch nicht ELI5 , aber Aufgeben ist die schlechteste Alternative.
VG
Yal
Den Code würde ich wie folgt "optimieren":
Sub Makro1()
With Range("B6:B14")
.FormatConditions.Add Type:=xlExpression, Formula1:="=UND($A3=""t"";$B3=""A0100"")"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1)
.Font.Color = RGB(0, 0, 0)
.Font.Name = "Wingdings"
.Interior.PatternColorIndex = xlAutomatic
.Interior.ThemeColor = xlThemeColorDark1
.Interior.TintAndShade = RGB(217, 217, 217)
.StopIfTrue = False
End With
End With
End Sub