I am attempting to write code which will insert Now() in cell L16 whenever the result of the formula in M19 changes due to entries elsewhere on the sheet. In my quest if found code written by mdmackillop posted on this forum which monitors the calculated value in E8 (E6+E7=E8) and repeats that value in E9 and changes the background color of E9 whenever the value in E8 changes due to an entry in E6 or E7. This is the closest thing to what I need that I have been able to find. Here is the code I am referring to:
So my question is how can I modify this to monitor cell M19 and if its value changes insert Now() in L16?Option Explicit 'Create variable to hold values Dim Monitored Private Sub Worksheet_Activate() Monitored = Range("E8").Value 'Read in value prior to any changes End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'Check target to determine if macro is triggered If Intersect(Target, Union(Range("E6"), Range("E7"))) Is Nothing Then Exit Sub 'Prevent looping of code due to worksheet changes Application.EnableEvents = False 'Compare monitored cell with initial value If Range("E8").Value <> Monitored Then 'Do things as a result of a change DoThings 'Reset Variable with new monitored value Monitored = Range("E8").Value End If 'Reset events Application.EnableEvents = True End Sub Private Sub DoThings() With Range("E9") .Formula = Range("E6") + Range("E7") If .Interior.ColorIndex = 6 Then .Interior.ColorIndex = 8 Else: .Interior.ColorIndex = 6 End If End With End Sub



Reply With Quote