möchte in einem bestimmten Zellbereich jede Zelle nach der Eingabe einfärben welche Zahl sie enthält bzw. ob es Text ist (bei Text immer schwarz mit weißer Schrift), wir ein Feld leer gelassen soll es in den Standard (keine Farbe, schwarze Schrift gehen). Dies hat soweit richtig funktioniert nur behandelt Excel ein leeres Feld gleich wie ein Feld mit der Zahl 0. Kann mir jemand helfen wie ich zwischen einem leeren Feld und einem Feld mit der Zahl 0 unterscheiden kann.
Danke
Peter
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, Zelle As Range
'Bereich anpassen!
Set rng = Intersect(Target, Range("A1:J1"))
If Not rng Is Nothing Then
Application.EnableEvents = False
For Each Zelle In rng
Select Case Zelle.Value
Case Is = Empty: Zelle.Interior.ColorIndex = 0
Case Is = 0: Zelle.Interior.ColorIndex = 3
Case Is = 1: Zelle.Interior.ColorIndex = 6
Case Is = 2: Zelle.Interior.ColorIndex = 4
Case Is = 3: Zelle.Interior.ColorIndex = 5
Case Is = 4: Zelle.Interior.ColorIndex = 16
Case Is = 5: Zelle.Interior.ColorIndex = 46
Case Is = 6: Zelle.Interior.ColorIndex = 7
Case Is = 7: Zelle.Interior.ColorIndex = 51
Case Is = 8: Zelle.Interior.ColorIndex = 45
Case Is = 9: Zelle.Interior.ColorIndex = 13
Case Else: Zelle.Interior.ColorIndex = 1
End Select
Select Case Zelle.Value
Case Is = Empty: Zelle.Font.ColorIndex = 1
Case Is = 0: Zelle.Font.ColorIndex = 1
Case Is = 1: Zelle.Font.ColorIndex = 1
Case Is = 2: Zelle.Font.ColorIndex = 1
Case Is = 3: Zelle.Font.ColorIndex = 1
Case Is = 4: Zelle.Font.ColorIndex = 1
Case Is = 5: Zelle.Font.ColorIndex = 1
Case Is = 6: Zelle.Font.ColorIndex = 1
Case Is = 7: Zelle.Font.ColorIndex = 2
Case Is = 8: Zelle.Font.ColorIndex = 1
Case Is = 9: Zelle.Font.ColorIndex = 2
Case Else: Zelle.Font.ColorIndex = 2
End Select
Next
Application.EnableEvents = True
End If
End Sub