Hello,
I am using the code below to add check boxes to column D when column C is populated. I would like these check boxes to disappear when cells in column C are blank again. Although the check boxes appear I am unable to make them disappear when column C goes blank. Please help what I am doing wrong.
I am using the code below to add check boxes to column D when column C is populated. I would like these check boxes to disappear when cells in column C are blank again. Although the check boxes appear I am unable to make them disappear when column C goes blank. Please help what I am doing wrong.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ToRow As Long
Dim LastRow As Long
Dim MyLeft As Double
Dim MyTop As Double
Dim MyHeight As Double
Dim MyWidth As Double
'--------------------------
LastRow = Range("C65536").End(xlUp).Row
For ToRow = 11 To LastRow
If Not IsEmpty(Cells(ToRow, "C")) Then
MyLeft = Cells(ToRow, "D").Left
MyTop = Cells(ToRow, "D").Top
MyHeight = Cells(ToRow, "D").Height
MyWidth = MyHeight = Cells(ToRow, "D").Width
ActiveSheet.CheckBoxes.Add(MyLeft, MyTop, MyWidth, MyHeight).Select
With Selection
.Caption = ""
.Value = xlOff
.Display3DShading = False
End With
End If
If IsEmpty(Cells(ToRow, "C")) Then
ActiveSheet.CheckBoxes.Delete
Selection.FormatConditions.Delete
End If
Next
End Sub