Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1560to1564
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 Formatirung in VBA mit Formel

Bedingte Formatirung in VBA mit Formel
24.05.2017 11:47:49
peterlijaba@gmail.com
Hallo zusammen
Ich möchte den unten stehenden Code so angepasst haben, dass anstatt der Wert
="x" 

folgende Formel erstellt wird:

=AF_Krit(B4)""
Der Makrorecoder schreibt leider immer

"=""AF_Krit(A4)"""""""""""
Mit nur die Hochkommas löschen funktioniert leider nicht.
Wie müsste der folgende Code angepasst werden?
    Range("Status").Select
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:="=""x"""
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
Danke
Viele Grüsse,
Peter

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Bedingte Formatirung in VBA mit Formel
24.05.2017 12:25:00
yummi
Hallo Peter

with Range("Status")
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="AF_Krit(B4)"""
.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
end with
obwohl das reichen müsste:

with Range("Status")
.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="AF_Krit(B4)"""
.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
end with
Gruß
yummi
Anzeige
AW: Formel immer noch als Text und falsche Regel
24.05.2017 13:16:24
peterlijaba@gmail.com
Hallo Yummi
Danke für Deine geschätzte Antwort, jedoch läuft der Code noch nicht ganz richtig. Die Formel wird ebenfalls als Text mit Hochkommas erstellt, anstatt als als eine Formel:
so:
="AF_Krit(B4)"""

anstatt so:
=AF_Krit(B4)""
was noch dazu kommt ist, dass die Bedingte Formatierung nicht als Regel "Formel zur Ermittlung der zu formatierenden Zellen verwenden", sondern fälschlicherweise die Regel "Nur Zellen formatieren, die enthalten" erstellt wird.
Hast Du eine Idee wie der Code anzupassen ist?
Danke
Gruss,
Peter
Anzeige
AW: Formel immer noch als Text und falsche Regel
24.05.2017 13:57:16
yummi
Hallo Peter,
diesmal getestet ;-)

With Range("Status")
.FormatConditions.Add Type:=xlExpression, Formula1:="=AF_Krit(B4)"""""
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Font
.Color = -16776961
.TintAndShade = 0
End With
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
Gruß
yummi
AW: Formel immer noch als Text und falsche Regel
24.05.2017 14:28:53
peterlijaba@gmail.com
Hallo yummi
Super, läuft perfekt, vielen DANK!
Viele Grüsse,
Peter

322 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige