View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default So many option buttons

Assuming that the optionbuttons are from the forms toolbar, if you select
them all and link them to a cell (right-click, Format ControlControl, 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)


"Leith Ross" wrote
in message ...

Hello Rmagic,

The easiest way is to first find the OptionButton that was selected
using a loop.
This code will place the OptionButton number in cell "A1". You can
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

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=484513