Link to home
Start Free TrialLog in
Avatar of Rayne
RayneFlag for United States of America

asked on

Clear data on all unchecked Excel

I was wondering if its possible to CLEAR ANY CONTENT ROWS OFF THE MAINvIEWsHEET if all the boxes and checkboxes are unchecked. Code going through all controls is Like this...

Dim ctl As CheckBox
Dim ctl1 As OLEObject
Dim bSelected As Boolean
bSelected = False

'Check CheckBox
For Each ctl In Sheet1.CheckBoxes
       If ctl.Value = 1 Then 'Checked
         bSelected = True
       End If
Next ctl

'Check Togglebutton
For Each ctl1 In Sheet1.OLEObjects
    If TypeOf ctl1.Object Is ToggleButton Then
        If ctl1.Object.Value Then
            bSelected = True
        End If
    End If
Next ctl1

If Not bSelected Then
    MsgBox "All unchecked"
End If
Avatar of Rayne
Rayne
Flag of United States of America image

ASKER

ASKER CERTIFIED SOLUTION
Avatar of dlmille
dlmille
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rayne

ASKER

Hi Dave,

Lost my internet connection for a day. I got your solution now. Thank you so much for being so helpful.

Rayne
Avatar of Rayne

ASKER

Your style of explanation makes it very easy to understand
Avatar of Rayne

ASKER

Hi Dave,
If you have a chance…this is another question..you may look here….
https://www.experts-exchange.com/questions/27687145/Search-excel-sequence.html?anchorAnswerId=37881586#a37881586
Thank you