1

In my excel sheet I put 2 OptionButton objects:

enter image description here

in my VBA macro I added:

Sub OptionButtonDebugOff_Click()
    debugmode = False
End Sub
Sub OptionButtonDebugOn_Click()
    debugmode = True
End Sub

and associated the object with resp. OptionButtonDebugOff_Click and OptionButtonDebugOn_Click (right-click on the "button" -> assign macro).

Event handling works fine ('debugmode' variable is changed to False when I click on the 'OptionButtonDedugOff').

I haven't found the VBA command to set a value to those OptionButton's , in particular at macro start, to make the button associated with OptionButtonDedugOff_Click checked (selected) by default (knowing that, besides, debugmode is set false at macro start).

Thanks for your advises!

6
  • 2
    Possibly, worksheets("SheetName").Shapes("ButtonName").ControlFormat.Value= xloff or xlon Commented Oct 21 at 12:47
  • Thanks @Natthan_Sav. I haven't managed to make this working ; what is "ButtonName" ? I don't see a place to set a name to the object , in particular in the Format Control popup (right-click on the "button" -> Format Control ) Commented Oct 21 at 15:06
  • 1
    When you select your button, its name will appear in the Name Box on the left side next to the formula bar. Commented Oct 21 at 15:14
  • It may be e.g. "Option Button 1" or equivalent in your language. You can use either English or local name. Commented Oct 21 at 15:20
  • Thanks @MGonet, did not see that cell ;) Commented Oct 21 at 16:08

3 Answers 3

2

You can use the following, replacing SheetName with your sheet name and ButtonName with the name of your Option Button name. This will be available just above where the top left cell is in Excel.

worksheets("SheetName").Shapes("ButtonName").ControlFormat.Value= xloff or xlon

Sign up to request clarification or add additional context in comments.

2 Comments

cheat sheet created from "Steve" I hope this aides you
0

Are you using ControlFormat ?

Is your approach to work with shapes? Perhaps manipulate the OptionBotton sate, 'if' button inserted as a Form Control.

New here .. Curious did you modify the .value property of the OptionBotton object?

2 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
I don't know the VBA commands to set the .value property of the OptionBotton object , this is actually my question.
0

If your OptionButtons are in ControlFormat this where you manipulate state, I do believe

This of course would depend if depending on whether you want the OptionButton selected ? Can be set either x1on or x10ff

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.