Changing the value of all checkboxes

artfult

New Member
Joined
Jul 11, 2016
Messages
2
Hi guys,

I have tried searching for an answer to my questions, however, I have had no luck - so it may not be possible but here goes..

I have created a userform with a considerable number of checkboxes, however, when I submit the data I would like the entry to read 'Yes' for a TRUE value and blank for a FALSE value.

Obviously, I can do this for individual boxes, but to add the code to each individual checkbox will take way too long.

Is there a piece of code I can insert to change the value for all checkboxes?

Thanks for all your help (not just on this query but all the others I have already had answered!)

Regards

ArtfulT
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Something like

Code:
Dim oneControl as msforms.Control

For each oneControl in Userform1.Controls
    If TypeName(oneControl) = "Checkbox" Then
        oneControl.Value = True
    End If
Next oneControl
 
Upvote 0
Thank you for the quick answer! However, as you may have guessed - I am an complete newb to VBA.

Where does this code go? I've thought it might be used when the userform initializes but no luck!

Thanks again.
 
Upvote 0
When the userform initializes, the checkbox values will be set to the defaults that you set in the VBEditor. (If you do nothing they will all be False, i.e. unchecked)

That code would go in the procedure in the userform's code module where you want all the checkboxes to be checked.
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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