Supportnet / Forum / Tabellenkalkulation
Farbänderung Schrift bei Datumswechsel
Frage
Hallo,
in einer Tabelle gebe ich in Spalte A das Datum ein. Zu besseren Übersicht möchte ich bei jedem Datumwechsel die Schriftfarbe von schwarz auf rot bzw von rot auf schwarz ändern ( siehe unten)
Wie kann man so etwas hin bekommen? Habe es schon mit Bedingter Formatierung versucht, komme aber zu keinen Ergebnis.
Schon mal Danke an alle die helfen
Gruß
Christian
A1 15.11.2007 Schriftfarbe = schwarz
A2 15.11.2007 schwarz
A3 15.11.2007 schwarz
A4 16.11.2007 rot
A5 16.11.2007 rot
A6 17.11.2007 schwarz
A7 19.11.2007 rot
A8 01.12.2007 schwarz
usw.
usw.
Antwort 1 von Marie
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
If Target.Font.ColorIndex = 3 Then
Target.Font.ColorIndex = 0
Else
Target.Font.ColorIndex = 3
End If
End Sub
Hier
Gruß marie
Antwort 2 von stoney
Hallo marie,
Danke, aber es funktioniert leider nicht so wie ich es mir vorgestellt habe.
Es kommt folgendes dabei heraus:
A1 15.11.2007 rot
A2 15.11.2007 schwarz..... soll rot
A3 15.11.2007 schwarz ..... soll rot
A4 15.11.2007 rot
A5 16.11 2007 rot ..................soll schwarz
A6 17.11 2007 rot
A7 17.11.2007 schwarz..........soll rot
A8 18.11.2007 schwarz.
A9 18.11.2007 schwarz
A10 18.11.2007 rot..................soll schwarz
Die Farben ändern sich im 3er Rytmus und nicht wie gewünscht bei jeder Datumsänderung. So lange sich Das Datum nicht ändert, soll sich die Schriftfarbe auch nicht ändern.
Vielleicht hast Du ja noch eine Idee....
Gruß
Christian
Danke, aber es funktioniert leider nicht so wie ich es mir vorgestellt habe.
Es kommt folgendes dabei heraus:
A1 15.11.2007 rot
A2 15.11.2007 schwarz..... soll rot
A3 15.11.2007 schwarz ..... soll rot
A4 15.11.2007 rot
A5 16.11 2007 rot ..................soll schwarz
A6 17.11 2007 rot
A7 17.11.2007 schwarz..........soll rot
A8 18.11.2007 schwarz.
A9 18.11.2007 schwarz
A10 18.11.2007 rot..................soll schwarz
Die Farben ändern sich im 3er Rytmus und nicht wie gewünscht bei jeder Datumsänderung. So lange sich Das Datum nicht ändert, soll sich die Schriftfarbe auch nicht ändern.
Vielleicht hast Du ja noch eine Idee....
Gruß
Christian
Antwort 3 von rainberg
Hallo Christian,
probier mal das
Gruß
Rainer
probier mal das
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
If Target.Value = Target.Offset(-1, 0).Value Then
If Target.Offset(-1, 0).Font.ColorIndex = 3 Then Target.Font.ColorIndex = 3
If Target.Offset(-1, 0).Font.ColorIndex = -4105 Then Target.Font.ColorIndex = -4105
End If
If Target.Value <> Target.Offset(-1, 0).Value Then
If Target.Offset(-1, 0).Font.ColorIndex = 3 Then Target.Font.ColorIndex = -4105
If Target.Offset(-1, 0).Font.ColorIndex = -4105 Then Target.Font.ColorIndex = 3
End If
End Sub
Gruß
Rainer
Antwort 4 von woher
Hallo,
wozu VBA?
nimm das bedingte Format:
Formel ist ; =REST(A1;2)=0
mfg
Wolfgang W.
wozu VBA?
nimm das bedingte Format:
Formel ist ; =REST(A1;2)=0
mfg
Wolfgang W.
Antwort 5 von stoney
Danke Rainer, Danke Wolfgang W. .....
beide Lösungen funktionieren.
SUPER SUPER
Gruß
Christian
beide Lösungen funktionieren.
SUPER SUPER
Gruß
Christian