AW: Musterdatei
18.06.2005 08:42:25
Hajo_Zi
Hallo Erich,
mal der Code für die bedingte Formatierung, da ist der Vergleich eingearbeitet.
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'* H. Ziplies *
'* 19.07.03, 30.10.03 *
'* erstellt von Hajo.Ziplies@web.de *
'* <a href="http://home.media-n.de/ziplies/">http://home.media-n.de/ziplies/</a> *
' HINTERGRUND
' für Schrift RaZelle.Font.ColorIndex
Dim RaBereich As Range, RaZelle As Range
' Bereich der Wirksamkeit
Set RaBereich = Range("B3:C20, D1:D7")
' noch mehr Bereiche
' Set RaBereich = Union(Range("C7:I26"), Range("L7:R26"), Range("U7:AA26"), Range("AD7:AJ26"))
' ab Vesion XP braucht der Schutz nicht aufgehoben werden
' Formatierung bei Schutz kann über Dialog Schutz eingestellt werden
' ActiveSheet.Unprotect ("Passwort")
For Each RaZelle In Range(Target.Address)
If Not Intersect(RaZelle, RaBereich) Is Nothing Then
With RaZelle
Select Case UCase(.Value) ' UMWANDLUNG DER Eingabe in Großbuchstaben
Case "1"
.Interior.ColorIndex = 1
' schwarz
.Font.ColorIndex = 2
' Schriftfarbe weiß
'.NumberFormat = "General"
' Zellenformat Standard
Case "2"
.Interior.ColorIndex = 6
' weiß
.Font.ColorIndex = 0
' Schriftfarbe automatisch
'.NumberFormat = "General"
' Zellenformat Standard
Case "3"
.Interior.ColorIndex = 3
' rot
.Font.ColorIndex = 2
' Schriftfarbe Weiß
'.NumberFormat = ";;;"
' nicht sichtbar
Case "4"
.Interior.ColorIndex = 4
' grün
.Font.ColorIndex = 0
' Schriftfarbe automatisch
'.NumberFormat = "General"
' Zellenformat Standard
Case "KLAUS"
.Interior.ColorIndex = 5
' blau
.Font.ColorIndex = 0
' Schriftfarbe automatisch
'.NumberFormat = "General"
' Zellenformat Standard
Case Else
.Interior.ColorIndex = xlNone
' Keine
.Font.ColorIndex = 0
' Schriftfarbe automatisch
'.NumberFormat = "General"
' Zellenformat Standard
End Select
End With
End If
Next RaZelle
' ActiveSheet.protect ("Passwort")
Set RaBereich = Nothing
End Sub
Gruß Hajo
Das Forum lebt auch von den Rückmeldungen.