mit einem teils aufgezeichneten und manuell nachgebesserten Makro markiere ich in einem kleinen Bereich über eine bedingte Formatierung die Zellen orange, die nicht gesperrt sind (schon mal sorry für ...select...).
Sub M_10_2_1()
'Alle nicht gesperrten Zellen werden über eine bedingte Formatierung orange gekennzeichnet
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=(ZELLE(""Schutz"";A1)=0)"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A1").Select
End Sub
Leider schaffe ich es nicht, genau nur diese Formatierung wieder mit VBA zu löschen.
Sub M_10_2_2()
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
With Selection.FormatConditions.Formula1: "=(ZELLE(""Schutz"";A1)=0)"
.Selection.FormatConditions(Selection.FormatConditions.Count).FirstPriority
.Selection.FormatConditions(1).Interior
.PatternColorIndex = 49407
.TintAndShade = 0
Selection.FormatConditions(1).Delete
End With
End Sub
Es erscheint ein Syntaxfehler bei "With Selection..." den ich nicht beheben kann.
Es muss genau nur diese bedingte Formatierung gelöscht werden, eine/alle anderen bedingten Formatierungen sollen bestehen bleiben.
Eine kleine Beispieldatei anbei: https://www.herber.de/bbs/user/110233.xlsm
Wie kann ich nur die bedingte Formatierung mit der o. g. Formel löschen, die an 1. Proi steht und die Farbe 49407 hat?
Grüße - Erwin