Auto Grouping of Option Buttons

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

Guest

I have a worksheet that has a dozen option button groups. This sheet is to be
copied/pasted in the same excel file more than 100 times. Is there a way to
have the option button groups change there groupname automatically, so that I
dont end up doing it manually 1100 times.

Thanks,
Rafat Inayat Elahi
 
Perhaps by using a macro to loop through your controls and manipulate the
required properties.
 
Is it possible if you could provide a link or some insight as to how to
accomplish that?

Thanks,
Rafat I Elahi
 
Sub ListData()
Dim obj As OLEObject
Dim sh As Worksheet
Dim ob As MSforms.OptionButton
Dim sh1 As Worksheet
Set sh1 = Worksheets.Add(after:=Worksheets(Worksheets.Count))
rw = 2
sh1.Cells(1, 1) = "Sheet"
sh1.Cells(1, 2) = "Object"
sh1.Cells(1, 3) = "GroupName"
For Each sh In Worksheets

If sh.Name <> sh1.Name Then
For Each obj In sh.OLEObjects
If TypeOf obj.Object Is MSforms.OptionButton Then
Set ob = obj.Object
sh1.Cells(rw, 1).Value = sh.Name
sh1.Cells(rw, 2).Value = ob.Name
sh1.Cells(rw, 3).Value = ob.GroupName
rw = rw + 1
End If
Next
End If
Next
End Sub

this gives you a sample of the structure of code you would need. It just
lists all the option buttons and their group names - it should be a short
step from there to assign new group names to them.
 

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