gruss
ralle
ralle
gruss
geri
bedingte Formatierung ist da wohl der Falsche Ansatz. Mit VBA damit die Farbe auch wieder zurückgestellt wird. Im Beispiel ist die Farbe rot Private Sub Workbook_BeforeClose(Cancel As Boolean) Private Sub Workbook_Open() Private Sub Workbook_SheetActivate(ByVal Sh As Object) Private Sub Workbook_SheetDeactivate(ByVal Sh As Object) Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Code eingefügt mit Syntaxhighlighter 1.16
In ein modil
Option Explicit
Public OldColorIndex As Variant
Public OldRange As String
Public Register As String
in DieseArbeitsmappe
Option Explicit
If OldRange <> "" Then ActiveSheet.Range(OldRange).Interior.ColorIndex = OldColorIndex
End Sub
OldRange = ActiveCell.Address
Register = ActiveSheet.Name
OldColorIndex = ActiveCell.Interior.ColorIndex
ActiveCell.Interior.ColorIndex = 3
End Sub
OldRange = ActiveCell.Address
OldColorIndex = ActiveCell.Interior.ColorIndex
ActiveCell.Interior.ColorIndex = 3
Register = ActiveSheet.Name
End Sub
If OldRange <> "" Then Worksheets(Register).Range(OldRange).Interior.ColorIndex = OldColorIndex
End Sub
' Beim 1. Aufruf ist OldRange noch undefiniert
If OldRange = "" Then
OldRange = Target.Address
OldColorIndex = Target.Interior.ColorIndex
' Setze Hintergrundfarbe der aktiven Selection auf Rot
Target.Interior.ColorIndex = 3
Else
' Setze alten Range auf alte Farbe
If Range(OldRange).Interior.ColorIndex = 3 Then
Range(OldRange).Interior.ColorIndex = OldColorIndex
End If
OldColorIndex = Target.Interior.ColorIndex
' Merke mir aktuellen Adresse für nächsten Aufruf
OldRange = Target.Address
' Setze Hintergrundfarbe der aktiven Selection auf Rot
Target.Interior.ColorIndex = 3
End If
End Sub
Gruß Hajo
ralle
da bin ich dann mal der Auffasung, ich habe genug arbeit in diesen Beitrag gesteck. Du hättest mal gleich zum Anfang die Aufgabe komplett beschreiben sollen.
Gruß Hajo
Damit läuft es nur in bestimmten Zellen und bei geschütztem Blatt. Nur noch étwas für deine Bedürfnisse anpassen.
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If [C1] = "Y" Then GoTo Ende2
Set Bereich = Range("B7:F59")
If Intersect(Target, Bereich) Is Nothing Then GoTo Ende ' Abbruch, wenn Aktion nicht im Zielbereich
ActiveSheet.Unprotect ("andre")
Cells.FormatConditions.Delete
Dim lngRow As Long
lngRow = ActiveCell.Row
Range(Cells(lngRow, 2), Cells(lngRow, 6)).FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=""iojöl89989k"""
Range(Cells(lngRow, 2), Cells(lngRow, 6)).FormatConditions(1).Interior.ColorIndex = 6
ActiveSheet.Protect ("andre")
Exit Sub
Ende:
If [C1] = "Y" Then GoTo Ende2
Set Bereich = Range("I7:L58")
If Intersect(Target, Bereich) Is Nothing Then Exit Sub ' Abbruch, wenn Aktion nicht im Zielbereich
ActiveSheet.Unprotect ("andre")
Cells.FormatConditions.Delete
Dim lngRow2 As Long
lngRow2 = ActiveCell.Row
Range(Cells(lngRow2, 9), Cells(lngRow2, 13)).FormatConditions.Add Type:=xlCellValue, Operator:=xlNotEqual, _
Formula1:="=""iojöl89989k"""
Range(Cells(lngRow2, 9), Cells(lngRow2, 13)).FormatConditions(1).Interior.ColorIndex = 6
ActiveSheet.Protect ("andre")
Ende2:
End Sub
Gruß Andre