Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1440to1444
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Bedingte Formatierung zwei Kriterien

Bedingte Formatierung zwei Kriterien
17.08.2015 13:22:54
Tom
Hallo,
wie lässt sich der Code auf eine weitere Bedingung mit einer anderen Formatierung erweitern? Ich möchte "b" oder "i" eintragen und dadurch soll die Schraffierungsfarbe abweichend sein.
'bedingte Formatierung, wenn in Spalte K ein "b" eingetragen ist
With .Range(.Cells(Zeile_Z1, 12), .Cells(Zeile_Z, 28))
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=$K7=""b"""
With .FormatConditions(1).Interior
.Pattern = 14 'xlPatternLightUp
.PatternThemeColor = xlThemeColorLight1
' .ColorIndex = xlAutomatic
.ColorIndex = 8
.PatternTintAndShade = 0
End With
End With
gruß tom

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Bedingte Formatierung zwei Kriterien
17.08.2015 15:21:39
AlexG
Hallo Tom,
du kannst eine weitere Formatierung mit einer weiteren Wtih Klammer ansprechen
z.B. so
With .Range(.Cells(Zeile_Z1, 12), .Cells(Zeile_Z, 28))
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=$K7=""b"""
    With .FormatConditions(1).Interior
        .Pattern = 14 'xlPatternLightUp 
        .PatternThemeColor = xlThemeColorLight1
        ' .ColorIndex = xlAutomatic 
        .ColorIndex = 8
        .PatternTintAndShade = 0
    End With
.FormatConditions.Add Type:=xlExpression, Formula1:="=$K7=""i"""
    With .FormatConditions(2).Interior
        .Pattern = 14
        .PatternThemeColor = xlThemeColorAccent4
        .ColorIndex = 8
        .PatternTintAndShade = 0
    End With
End With

Gruß
Alex

Anzeige
AW: Bedingte Formatierung zwei Kriterien
17.08.2015 15:48:45
Tom
Hallo Alex,
passt! Vielen Dank.
With .FormatConditions(2) habe ich übersehen gehabt.
gruß Tom

Bitte, gern geschehen Gruß (owT)
17.08.2015 15:54:28
AlexG

AW: Bedingte Formatierung zwei Kriterien
17.08.2015 16:36:48
Tom
Hallo noch einmal,
eine Frage habe ich noch. Wenn in der Zelle $K7 ein k oder i gesetzt wird, soll in der Zelle $AC7 ein ja eingetragen werden oder je nach Zeichen in $K7 auch ein nein. Wie lässt sich das am besteln lösen. Folgenden Code habe ich bisher stehen.
    'Datengültigkeit mit Drop-Down-Auswahl in Spalte K einfügen
With .Range(.Cells(Zeile_Z1, 11), .Cells(Zeile_Z, 11)).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="k,b,i,u,a"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Auswahl für Art"
.InputMessage = ""
.ErrorMessage = "Zulässig sind nur Wert "" b = bl. Punkt; k = n. Kundenwunsch; i = Info, _
u = Update, a = Ablehnung"""
.ShowInput = False
.ShowError = True
End With
'Datengültigkeit mit Drop-Down-Auswahl in Spalte AC einfügen
With .Range(.Cells(Zeile_Z1, 29), .Cells(Zeile_Z, 29)).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="ja, nein"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "Auswahl für Umsetzung"
.InputMessage = ""
.ErrorMessage = "Zulässig sind nur Wert "" ja oder nein"""
.ShowInput = False
.ShowError = True
End With
'bedingte Formatierung, wenn in Spalte K ein "b" eingetragen ist
With .Range(.Cells(Zeile_Z1, 12), .Cells(Zeile_Z, 28))
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=$K7=""b"""
With .FormatConditions(1).Interior
.Pattern = 14 'xlPatternLightUp
.PatternThemeColor = xlThemeColorLight1
' .ColorIndex = xlAutomatic
.ColorIndex = 8
.PatternTintAndShade = 0
End With
'bedingte Formatierung, wenn in Spalte K ein "i" eingetragen ist
.FormatConditions.Add Type:=xlExpression, Formula1:="=$K7=""i"""
With .FormatConditions(2).Interior
.Pattern = 14
.PatternThemeColor = xlThemeColorAccent4
.ColorIndex = 4
.PatternTintAndShade = 0
End With
'bedingte Formatierung, wenn in Spalte K ein "u" eingetragen ist
.FormatConditions.Add Type:=xlExpression, Formula1:="=$K7=""u"""
With .FormatConditions(3).Interior
.Pattern = 14
.PatternThemeColor = xlThemeColorAccent4
.ColorIndex = 15
.PatternTintAndShade = 0
End With
'bedingte Formatierung, wenn in Spalte K ein "a" eingetragen ist
.FormatConditions.Add Type:=xlExpression, Formula1:="=$K7=""a"""
With .FormatConditions(4).Interior
.Pattern = 14
.PatternThemeColor = xlThemeColorAccent4
.ColorIndex = 3
.PatternTintAndShade = 0
End With
End With

Gruß Tom

Anzeige
WENN- Formel
17.08.2015 17:01:03
AlexG
Hallo Tom,
das kannst du mit einer WENN- Formel in AC7 löesen.
=WENN(ODER($K7="k";$K7="i");"ja";"nein")
oder die Formel per VBA eintragen.
Range("AC7").FormulaR1C1 = "=IF(OR(RC11=""k"",RC11=""i""),""ja"",""nein"")"
Gruß
Alex

AW: WENN- Formel
20.08.2015 17:00:07
Tom
Hallo,
ich hab den Code mal versucht. Aber die VBS Formel spricht nur die erste Zeile an. Was passt nicht?
'    bedingte Formatierung, wenn in Spalte K ein "b, i, u" steht wird in Spalte AC ein "ja"  _
eingetragen sonst "offen"
Range("AC7").FormulaR1C1 = "=IF(OR(RC11=""b"",RC11=""i"",RC11=""u""),""ja"",""offen"")"
gruß tom

Anzeige
AW: WENN- Formel
20.08.2015 17:25:05
AlexG
Hallo Tom,
du musst dann den Bereich in dem die Formel eingetragen werden soll anpassen.
z.B. wenn die Formel bis Zeile 99 eingetragen werden soll
Range("AC7:AC99") = Formula.....
Gruß
Alex

301 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige