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
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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