Active x/userform/ or normal worksheet controls

Eisasuarez

Well-known Member
Joined
Mar 23, 2012
Messages
653
Hi,

i have seen many times people always ask when referring to controls, is it a form, normal or active x control?

now my question is which one is easier to use?
are the coding side to reference these controls different and do you reference the different type of controls?

why is this question always asked as im presuming there must be a major difference in referencing different controls?

if someone can give a list n code examples that would be really appreciated
 

Some videos you may like

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,067
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
The question is asked because the controls work differently. Forms controls for instance have limited formatting options and you assign macros to them; ActiveX controls have more options and more events that you can work with, but they are also generally not as stable on worksheets.

There are different ways to refer to the controls in code. For example:

Forms checkbox:
Code:
        Dim cb As Excel.CheckBox
    Set cb = ActiveSheet.CheckBoxes("Check Box 1")
    MsgBox cb.Value
    
    Dim cf As ControlFormat
    Set cf = ActiveSheet.Shapes("Check Box 1").ControlFormat
    MsgBox cf.Value

ActiveX checkbox:
Code:
    Dim cb As MSForms.CheckBox
    Set cb = ActiveSheet.CheckBox1
    MsgBox cb.Value
    
    Set cb = ActiveSheet.OLEObjects("CheckBox1").Object
    MsgBox cb.Value
 

Watch MrExcel Video

Forum statistics

Threads
1,122,564
Messages
5,596,878
Members
414,106
Latest member
Tigretto

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
Top