Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1108to1112
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

Laufzeitfehler bei bedingter Formatierung

Laufzeitfehler bei bedingter Formatierung
Steffen
Guten Tag,
wie der Titel schon sagt bekomme ich einen Laufzeitfehler wenn ich die bedingte Formatierung anwende.
Cells(5, 23).Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="24"
Selection.FormatConditions(1).Font.ColorIndex = 6
Selection.FormatConditions(1).Interior.ColorIndex = 3
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, Formula1:="4", Formula2:="24"
Selection.FormatConditions(2).Font.ColorIndex = xlAutomatic
Selection.FormatConditions(2).Interior.ColorIndex = 15
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula1:="4"
Selection.FormatConditions(3).Font.ColorIndex = 15
Selection.FormatConditions(3).Interior.ColorIndex = 15
kann mir jemand sagen, woran es liegt?
Vielen Dank im voraus

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
bedingte Formatierung mit VBA
08.10.2009 11:23:11
Erich
Hi Steffen,
wenn für die Zelle schon ein bed. Format definiert ist, wird es eng.
Du musst diese bed. Formatierungen dann vorher löschen:

Sub aaa()
With Cells(5, 23)
With .FormatConditions
If .Count > 0 Then .Delete
End With
.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, Formula1:="24"
.FormatConditions(1).Font.ColorIndex = 6
.FormatConditions(1).Interior.ColorIndex = 3
.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
Formula1:="4", Formula2:="24"
.FormatConditions(2).Font.ColorIndex = xlAutomatic
.FormatConditions(2).Interior.ColorIndex = 15
.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, Formula1:="4"
.FormatConditions(3).Font.ColorIndex = 15
.FormatConditions(3).Interior.ColorIndex = 15
End With
End Sub
Das Select ist vermutlich unnötig - ich habe es durch eine With-Klammer ersetzt.
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort
Anzeige
AW: bedingte Formatierung mit VBA
08.10.2009 16:08:54
Steffen
Läuft
Vielen Dank
Excel will das nicht überschreiben also erst löschen und dann machen!
Add heisst Hinzufügen
08.10.2009 16:44:03
Erich
Hi Steffen,
das wäre ja noch schöner, wenn Excel/VBA bei einem Add einfach etwas überschreiben würde.
Was würde denn dann beim 2. und 3. Add in deiner Prozedur passieren?
Da WILLST du hinzufügen, ohne das Vorherige zu löschen.
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige