You need to use the checkbox property that refers to your corresponding string. Either (if bound) use .LinkedCell (the line then receives the range object), or if it is located in the corresponding line, then .TopLeftCell (range)
eg:.
'Using LinkedCell Range(cb.LinkedCell).EntireRow.Range("H1:L1").Delete 'or using TopLeftCell cb.TopLeftCell.EntireRow.Range("H1:L1").Delete cb.Value = -4146 'uncheck the checkbox
An example of your code with the above and added check if the checkbox is checked:
Sub EliminateCheckBoxes() Dim CB As CheckBox, n As Long, x As Long n = ActiveSheet.CheckBoxes.Count For x = n To 1 Step -1 Set CB = ActiveSheet.CheckBoxes(x) If CB.Name <> "Check Box 1" Then 'are you intentionally excluding Check Box 1? If CB.Value = 1 then CB.TopLeftCell.EntireRow.Range("H1:L1").ClearContents CB.Value = -4146 'uncheck the checkbox End If End If Next x End Sub
source share