Togglebutton states

AndyEd

Board Regular
Joined
May 13, 2020
Messages
124
Office Version
  1. 365
Platform
  1. Windows
In a userform I have a number of togglebuttons that are in an 'unselected' state when the form loads. During the course of completion the user clicks on the togglebuttons to change their state to either 'true' or 'false', 'on' or 'off', '1' or '0', whichever way you want to look at it..

I want to incorporate a cmdbutton to reset the selections, from which I would like to have the togglebuttons revert to their 'unselected' state.

Is that possible? I have used 'null' as an option but that doesn't seem to work.

Any help would be appreciated.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
You should be able to modify this to get the results you're looking for:
VBA Code:
Sub unSelect()
Dim opb(), cnt As Control, i As Long
UserForm1.Show vbModeless
For Each cnt In UserForm1.Controls
    If TypeName(cnt) = "ToggleButton" Then
        ReDim Preserve opb(i)
        opb(i) = cnt.Name
        i = i + 1
    End If
Next cnt
For i = 0 To UBound(opb)
    UserForm1.Controls(opb(i)) = False
Next i

End Sub
 
Upvote 0
A reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:
Set 'unselected' state for togglebutton

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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