Option Explicit
Private oCellColorMonitor As C_CellColorChange
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call StopWatching
End Sub
Private Sub Workbook_Open()
Call StartWatching
End Sub
Public Sub CellColorChanged(Cell As Range, PrevColor As Variant, NewColor As Variant, Cancel As Boolean)
Const MSG1 As String = "You are trying to change the Color of Range : "
Const MSG2 As String = "Do you want to go ahead ?"
If MsgBox(MSG1 & Cell.Address & vbNewLine & MSG2, vbQuestion + vbYesNo) _
= vbNo Then
Cancel = True
Else
With Sheets("Log")
.Cells(1, 1).End(xlDown).Offset(1) = Cell.Address
.Cells(1, 1).End(xlDown).Offset(0, 1).Interior.Color = PrevColor
.Cells(1, 1).End(xlDown).Offset(0, 2).Interior.Color = NewColor
.Cells(1, 4).End(xlDown).Offset(1) = Format(Date, "dd/mm/yyyy") & _
" @ " & Format(Time, "hh: mm: ss ")
.Cells(1, 5).End(xlDown).Offset(1) = Environ("Username")
End With
End If
End Sub
Private Sub StartWatching()
Set oCellColorMonitor = New C_CellColorChange
oCellColorMonitor.ApplyToSheet Sheets(1) [B][COLOR=#00ff00]'change target sheet as required [/COLOR][/B]
oCellColorMonitor.StartWatching
End Sub
Private Sub StopWatching()
Set oCellColorMonitor = Nothing
End Sub