Changing all checkboxes with no value to False: VBA Code

mday1

New Member
Joined
Jul 5, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. Web
I have over 100 activeX checkboxes on a sheet. Some of the checkboxes are already checked/unchecked so I want the macro to ignore those. I found a macro to change all checkboxes to false but I'd like to modify the code to only change the value to False if the Value field in the properties box is blank. I tried modifying .Value = Null but it didn't work. Here is the code I found:

VBA Code:
Sub Clear_Checkboxes()

For Each ckb In ActiveSheet.OLEObjects
    'Will change True, tried Null but doesn't work
    If ckb.Object.Value = True Then
        
        ' set checkbox to false
        ckb.Object.Value = False
   
     End If

Next ckb

End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Use the IsNull function instead...

VBA Code:
If IsNull(ckb.Object.Value) Then

Hope this helps!
 
Upvote 0
Solution

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top