How to reference a shape by name and what else can be used in .Select?

6,322

If you are using Form Control OPTION BUTTON then the different command should be used.

Below are few examples:

ActiveSheet.OptionButtons("Option Button 1").Select

ActiveSheet.Shapes("Option Button 1").ControlFormat.Value = Xlon

Range("A1")=Activesheet.OptionButtons("Option Button 1").value

ActiveSheet.OptionButtons("Option Button 1").LinkedCell = "Sheet1!$A$1"

or

 ActiveSheet.Shapes("Option Button 1").ControlFormat.LinkedCell = "Sheet1!$A$1"

To Run Macro on Option Button Click:

ActiveSheet.Shapes("Option Button 1").OLEFormat.Object.OnAction = "Module1.MyMAcro"
Share:
6,322

Related videos on Youtube

Kenny
Author by

Kenny

Updated on September 18, 2022

Comments

  • Kenny
    Kenny over 1 year

    I use MS Excel 2007

    My question is in two parts

    I have a form option button called "Option1"

    1. How do I refer to that button in other macros? I know that I can select it using: ActiveSheet.Shapes("Option1").Select

    but I really only need to use something like

    ActiveSheet.Shapes("Option1") Doing this throws an error in VBA.

    2. Taking ActiveSheet.Shapes("Option1").Select

    Is there a list or resource that shows what else can be used where the .Select part is?