AW: Bedingte Formatierung in Makro umbauen
29.03.2019 13:08:32
fcs
Hallo Thomas,
hier mein Vorschlag.
Mit zusätzlihen Bedingungen in den Formeln kann der gesamte Zellbereich in einem Rutsch formatiert werden.
Makro wurde für Deutsches Excel erstellt. Wenn Sprache anders, dann müssen die Funktionen REST, ZEILE
und SPALTE im Code entsprechend erstzt werden.
LG
Franz
Sub prcBdengteFormatierung()
Dim wks As Worksheet, rngFormat As Range
Set wks = ActiveSheet
Set rngFormat = wks.Range("E5:AD72")
With rngFormat
.Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=(REST(SPALTE();2)=0)*(REST(ZEILE();2)=1)*(D5>0)*((D5""CW"")*(D5>=D6)*(D6"""")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = VBA.RGB(red:=0, green:=255, blue:=0)
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=(REST(SPALTE();2)=0)*(REST(ZEILE();2)=1)*((D6="""")*((D5-$A$92)=0))"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = VBA.RGB(red:=255, green:=255, blue:=0)
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=(REST(SPALTE();2)=0)*(REST(ZEILE();2)=1)*(E5=""a"")"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = VBA.RGB(red:=0, green:=255, blue:=0)
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End With
End Sub