ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying OptionButtons (https://www.excelbanter.com/excel-programming/404061-copying-optionbuttons.html)

samela

Copying OptionButtons
 
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!!

Dave Peterson

Copying OptionButtons
 
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.


samela wrote:

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!!


--

Dave Peterson

samela

Copying OptionButtons
 
On Jan 11, 11:10*pm, Dave Peterson wrote:
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.





samela wrote:

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!!


--

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?

Dave Peterson

Copying OptionButtons
 
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.



samela wrote:

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?


--

Dave Peterson


All times are GMT +1. The time now is 10:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com