VBA code for to-do checklist where if any task deleted corresponding checkbox will be uncheck by itself
Copy Below VBA code and paste under sheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngTasks As Range
Dim rngChanged As Range
Dim Cell As Range
'Set the range for tasks in column C
Set rngTasks = Me.Range("C:C")
Set rngChanged = Intersect(Target, rngTasks)
'Check if any changes intersect with the tasks range
If Not Intersect(Target, rngTasks) Is Nothing Then
Application.EnableEvents = False 'Disable events to prevent re-triggering
For Each Cell In rngChanged
'If the task in column C is deleted, clear the corresponding text in column A
If Cell.Value = "" Then
Cell.Offset(0, -2).ClearContents 'Offset by -2 columns (Column A)
End If
Next Cell
Application.EnableEvents = True 'Re-enable events
End If
End Sub
Dim rngTasks As Range
Dim rngChanged As Range
Dim Cell As Range
'Set the range for tasks in column C
Set rngTasks = Me.Range("C:C")
Set rngChanged = Intersect(Target, rngTasks)
'Check if any changes intersect with the tasks range
If Not Intersect(Target, rngTasks) Is Nothing Then
Application.EnableEvents = False 'Disable events to prevent re-triggering
For Each Cell In rngChanged
'If the task in column C is deleted, clear the corresponding text in column A
If Cell.Value = "" Then
Cell.Offset(0, -2).ClearContents 'Offset by -2 columns (Column A)
End If
Next Cell
Application.EnableEvents = True 'Re-enable events
End If
End Sub