Friday, August 11, 2023

Auto Uncheck checkBox If Corresponding Cell Task/Text Removed/Cleared

 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


How To Use Vlookup In Merged Cells

  How To Use Vlookup In Merged Cells Click Here to download sample file for practice Note: Download the file and open with microsoft excel