Table of Contents • • • • • • • • • • • • • • • Introduction This VBA Guide will teach you everything you ever wanted to know about handling Excel Form Control Option Buttons using VBA. By “Form Control” option buttons, also known as radio buttons, I mean this fellow located under “Form Controls” on the > Insert menu: Form Control Option Button If you want to read more complete guides to Form Control or ActiveX Controls, visit my page. I created an order form using Excel Form Control Option Buttons, or radio buttons. I’ll reference this order form throughout the guide as we learn how to manipulate our option buttons with VBA macros. Excel Option Button Form Remember, you can only select one option button at a time, unless you place them in different “groups.” These groups are also called “Frames” or “Group Controls.” In my sample form, I placed the color radio buttons in their own group so the user can select both a size AND a color. This website gets picked on a lot for using Excel 2010. I know I’m half a dozen years behind the times - I’m okay with that! Anyway, keep reading to learn how to check, uncheck, assign a macro to and loop through all form control option buttons! Jump to Return the Value of your Option Button There’s more than one way to check the value of a form control option button. I’ll present three ways. The following macros return the value of an option button named “ Option Button 1” and store the value in the variable rbValue. Remember, the option button name can be found in the upper left of Excel when you have your option button selected: Option Button 1 Method 1. ★ ★ ★ ★ ☆ Excel Add-in All three methods do the same thing, so it’s up to personal preference. There are two possible values of an option button. Value Example Description 1 Checked (xlOn) -4146 Unchecked (xlOff) Jump to Checking/Unchecking your Option Button Checking and unchecking your Option Button (Radio Button) is almost identical to returning the value of your option button. Again, at least three methods can be used.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
May 2018
Categories |