How to add multiple option buttons

smiler44

Registered User.
Local time
Today, 11:25
Joined
Jul 15, 2008
Messages
671
merry christmas.
I want to add say 20 option buttons but to make sure they are the same size and all in line and so I can do this in future, I want to use a macro to a create the buttons and position then. I can create 1 button using
[code
ActiveSheet.OptionButtons.Add(100.3, 200.4, 8.5, 17.25).Select '100 across 200 down 8 width

Selection.Characters.Text = ""
[/code]

to create the 2nd and 3rd I need the 200 to increment and it is adding the variable to the code that has me stuck. this is what I thought but its wrong
as it does not like the variable.

I know my loop is never ending but i'm using the f8 key so ignore this please


Code:
 Dim a As Long

     ActiveSheet.OptionButtons.Add(100.3, 200.4, 8.5, 17.25).Select  '100 across 200 down 8 width
  
  
 a = 300
  
 do
     ActiveSheet.OptionButtons.Add(100.3, a.4, 8.5, 17.25).Select  
   Selection.Characters.Text = ""
 a = a + 100
 loop
  
  
 [code/]
  
 please can you help me? thanks
 smiler44
 
got it.

Code:
 Sub Macro3()
Dim a As Integer
 ActiveSheet.OptionButtons.Add(100.3, 200.4, 8.5, 17.25).Select  '100 across 200 down 8 width
 a = 225.4
Do
            ActiveSheet.OptionButtons.Add(100.3, a, 8.5, 17.25).Select  '100 across 200 down 8 width
   Selection.Characters.Text = ""
   a = a + 25
   
   Loop
End Sub

smiler44
 
Would you please upload a small demo of Excel?
Let me get some free time and see how it works and offer any suggestions.
 
Would you please upload a small demo of Excel?
Let me get some free time and see how it works and offer any suggestions.

RX_ my second post does the job but be warned, it's not a do until loop, just a loop so only run it by the f8 key.

smiler44
 

Users who are viewing this thread

Back
Top Bottom