Copying OptionButtons

  • Thread starter Thread starter samela
  • Start date Start date
S

samela

Hey there,

I've been copying my spreadsheets and all the active controls seem to
work fine except the option buttons. Everytime I click on a button
from my old sheet, the selected option disappears from my new sheet.
Does anyone know why this might be the case?

I tried changing the names of the option buttons and then the names in
the codes but that didn't work and the only thing that seemed to was
when I drew new option buttons and reprogrammed everything.

Is there an easier way around this than having to draw new option
buttons each time?

Thanks!!
 
Each optionbutton has a .groupname property.

You'll want to give each group of optionbuttons a nice unique name.

show the control toolbox toolbar
click on the design mode icon
Rightclick on each option button
change the groupname on each sheet (or for each group on each sheet) to
something unique
turn off the design mode

And test it out.
 
Each optionbutton has a .groupname property.

You'll want to give each group of optionbuttons a nice unique name.

show the control toolbox toolbar
click on the design mode icon
Rightclick on each option button
change the groupname on each sheet (or for each group on each sheet) to
something unique
turn off the design mode

And test it out.










--

Dave Peterson- Hide quoted text -

- Show quoted text -


Thanks, Dave :)

Is there a way to get the change to be automatic with each new sheet I
copy? Instead of having to change each of the GroupName(s) manually
each time I work with a new sheet?
 
Not that I know of.

But you could use a macro to change the groupnames in each worksheet to the
worksheet's name.

This'll use the codename of the worksheet.

Option Explicit
Sub testme()

Dim myOptBtn As OLEObject
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
For Each myOptBtn In wks.OLEObjects
If TypeOf myOptBtn.Object Is MSForms.OptionButton Then
myOptBtn.Object.GroupName = wks.CodeName
End If
Next myOptBtn
Next wks
End Sub


Don't use this if you have optionbuttons that are in different groups on the
same sheet. It'll put all the optionbuttons on the sheet in one group.
 

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