So many option buttons

  • Thread starter Thread starter Rmagic
  • Start date Start date
R

Rmagic

hello again

I have a form with 31 option buttons (for different colours) and
command button

How do i send which option button (which number) has been selected to
sheet cell from the command button only 1 selection is poss

Thank yo
 
Hello Rmagic,

The easiest way is to first find the OptionButton that was selecte
using a loop.
This code will place the OptionButton number in cell "A1". You ca
change the cell to what you need as well as the max loop value of 31
This code assumes all the OptionButton numbers are sequential.


Code
-------------------

Dim OB As Object

For I = 1 To 31
Set OB = Controls("OptionButton" & I)
If OB.Value = True Then
Range("A1").Value = I
Exit Loop
End If
Next I
 
Hello Norman,

Thanks for catching that mistake. I'm sure Rmagic appreciates it a
well.

Sincerely,
Leith Ros
 
Assuming that the optionbuttons are from the forms toolbar, if you select
them all and link them to a cell (right-click, Format Control>Control, cell
link), then that cell will contain an index number that you can use in code
or in worksheet functions.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

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