Farbe bei betreten der Zelle
Stefanglander
habe hier etwas sehr interessantes gefunden.
Option Explicit
Function ColorFromPallet(Optional lOldCol As Double = xlNone) As Double
Dim dSavCol As Double, dNewCol As Double
Dim iRGB_R As Integer, iRGB_G As Integer, iRGB_B As Integer
dSavCol = ActiveWorkbook.Colors(32)
If lOldCol = xlNone Then
ColIx2RGB 13160660, iRGB_R, iRGB_G, iRGB_B
Else
ColIx2RGB lOldCol, iRGB_R, iRGB_G, iRGB_B
End If
If Application.Dialogs(xlDialogEditColor).Show _
(32, iRGB_R, iRGB_G, iRGB_B) Then
ColorFromPallet = ActiveWorkbook.Colors(32)
ActiveWorkbook.Colors(32) = dSavCol
Else
ColorFromPallet = lOldCol
End If
End Function
Sub ColIx2RGB(ByVal lCol As Long, _
iR As Integer, iG As Integer, iB As Integer)
iR = lCol Mod 256: lCol = lCol \ 256
iG = lCol Mod 256: lCol = lCol \ 256
iB = lCol Mod 256
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rZellen As Range
Dim LColor As Double
Set rZellen = Intersect(Target, Range("a1:a3"))
If Not rZellen Is Nothing Then
LColor = ColorFromPallet
If LColor xlNone Then
rZellen.Interior.Color = LColor
ElseIf MsgBox("Sollen die Farben im Bereich gelöscht werden?", vbYesNo) = vbYes Then
rZellen.Interior.Color = xlNone
End If
End If
End Sub
Wie muss ich den Code ändern das nicht mehr der Bereich A1:A3 sondern A1:A3, C4 und F5:F8 angesprochen werden?
Danke vorab
Stefan