How to create a Macro to Name a Checkbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way that I can create a macro to allow me to click a button within
a worksheet that will allow me specify a name for a checkbox?
 
for control toolbox toolbar controls, you can use

activesheet.OleObjects(2).Name = "OptionButton8"

for optionbuttons from the forms toolbar
activesheet.Optionbuttons(2).Name = "OptionButton8"

If you really meant the caption, then change Name to be Caption.
 
Tom,
Thanks for the quick response.

I was able to use this as long as I keep it as you have it stated with the
".Name".

I do need it to change for the caption though and when I change ".Name" to
".Caption" i receive a debug error code 438. It states: Object doesn't
support the property or method.
 
Tom,
i figured out what I was doing wrong. I had to modify your example of:

activesheet.Optionbuttons(2).Name = "OptionButton8"

To:

ActiveSheet.CheckBox1.Caption = "OptionButton8"

Thank-you much for all of the assistance.
 
Yes. My error. For control toolbox Toolbar option buttons you would add
"Object" as shown in this demo from the immediate window:

? activesheet.OleObjects(1).Object.Caption
OptionButton1
Activesheet.OleObjects(1).Object.Caption = "House"
? activesheet.OleObjects(1).Object.Caption
House
 
That wouldn't be meaningful in code unless you just added the Checkbox.
Hard coding the name of the control in your code, at least to me, doesn't
make sense to perform that type of action. I have posted an alternative
method elsewhere in the thread.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top