Using a combination of the Worksheet_Change, Worksheet_SelectionChange and a global variable (in a module), this may work for you.
The following code goes into the worksheet code module for the sheet with your tasks/dates (right-click tab, select View Code, paste this code into the VB editor)
Private Sub Worksheet_Change(ByVal Target As Range)
' Don't run macro if multiple cells changed at once
If Target.Cells.Count > 1 Then Exit Sub
' Check if the Target cell (acted upon cell) intersects with Column A.
If Not Intersect(Target, Range("A:A")) Is Nothing Then
' If target cell is blank, delete date from column B.
If Target.Value = "" Then
Target.Offset(0, 1).Value = ""
' Else, if target cell value is different from lastCell variable
' that was updated when you selected the cell, then update the
' date in column B.
ElseIf Target.Value <> lastCell Then
Target.Offset(0, 1).Value = Date
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
lastCell = Target.Value
End Sub
This line of code sets a global variable, and goes in a module. In the VB Editor, click Insert > Module, then paste this line. It basically captures the cell value of any cell you click on while on the sheet with the 'SelectionChange' event code. This is so it can compare the previous value with the new value. (If the cell was "Test Task 1", and you re-type "Test Task 1", you probably don't want the date to change, hence this check. If it was "Test Task 1" and now it's "Test Task 2", a new date will appear in column B.)
Global lastCell As Variant
Bookmarks