How to Activate a Toggle Button in VBA

Written by alexander gokhfeld | 13/05/2017
How to Activate a Toggle Button in VBA
The toggle controls help programmers design option forms in VBA applications. (Jupiterimages/ Images)

Microsoft Visual Basic for Applications (VBA) allows programmers to use different control objects on the user forms. The object can correspond to the box, image, scroll bar or button controls. A toggle button on a form is a control used to display a "Yes/No" value from a data source. Software developers use toggle buttons in an option group with other buttons and in dialogue boxes to accept user input. When you click a toggle button object, it appears to be pressed or pushed down. You need to obtain the value of a toggle button control in order activate the toggle button in VBA.

Click the "Start" button in Windows and select the "Microsoft Excel" from the "All Programs" menu to open a new workbook.

Click the "Tools," "Macro" and "Visual Basic Editor".

Click "Insert," then "UserForm" to insert a user form in your workbook.

Add the "ToggleButton" and "Label" controls on the user form.

Double-click the "ToggleButton" control to open the "Code" window for the ToggleButton control.

Enter the following code for the "ToggleButton1Click event:

Click the "Run Sub/UserForm" on the "Run" menu to activate the toggle button in your VBA control.

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.