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

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?

1 Answer

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"

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like