Gruppe
Ereignis
Problem
Bei Eingabe eines Buchstabens in Spalte A soll sich die Hintergrundfarbe gemäß der Tabelle Colors ändern.
ClassModule: Tabelle1
Private Sub Worksheet_Change(ByVal Target As Range)
Dim vRow As Variant
If Target.Column <> 1 Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
If IsEmpty(Target) Then
Target.Interior.ColorIndex = xlColorIndexNone
Else
With Worksheets("Colors")
vRow = Application.Match(UCase(Target.Value), .Columns(1), 0)
If Not IsError(vRow) Then
Target.Interior.ColorIndex = .Cells(vRow, 1).Interior.ColorIndex
End If
End With
End If
End Sub
StandardModule: Modul1
Sub FarbenAnlegen()
Dim iRow As Integer
With Worksheets("Colors")
For iRow = 1 To 26
With Cells(iRow, 1)
.Value = Chr(iRow + 64)
.Interior.ColorIndex = iRow + 1
End With
Next iRow
End With
End Sub