0
Ich habe eine Frage: Ich versuche, zwei verschiedene bedingte Formatierung auf einmal zu machen. Aber es funktioniert nur der zweite. Im mit wenn und Elseif, und arbeiten nur endif Was ich zu schreiben, sie zu erhalten arbeiten beide? Erst einer nach dem anderen?bedingte Formatierung VBA mit if
For Each cell In Range("A1:AA1")
If cell.Value = "GM WP6 Sensor Status" Then
Cells.FormatConditions.Delete
Columns("H:H").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=32671"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
'Selection.FormatConditions(1).StopIfTrue = False
Columns("H:H").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=LEN(TRIM(H1))=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.Pattern = xlNone
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A1").Select
''''''''''''''''''''''''''Tikrina kita
ElseIf cell.Value = "GM WP6 Sensor Status light" Then
Cells.FormatConditions.Delete
Columns("I:I").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=32767"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Columns("I:I").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=LEN(TRIM(I1))=0"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.Pattern = xlNone
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Range("A1").Select
End If
Next cell
Laufzeitfehler 5. Ungültiger Prozeduraufruf oder Argument. An dieser Stelle: Spalten ("H: H"). FormatConditions.Add Typ: = xlExpression, Formula1: = _ "= UND (LEN (TRIM (H1))> 0, H1 <> 32671)" –
Ich mache einige Korrekturen es funktioniert jetzt :) danke @sktneer –
@SkirmanteValentaite Gern geschehen! :) – sktneer