Use the Option box value in a module

T

Tempy

Hi all, i hope i explain this correctly. I have 3 option boxes on a form
that you can select one of them. I then go into the module code and need
to know which option button is true and not being a programmer i am not
sure how to do it. Could somebody please help?

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
 
R

RonaldF

'UserForm1 is the name of the form
'OptionButton1 is the name of the first button

If UserForm1.OptionButton1.Value = True Then MsgBox "OptionButton1 selected"
If UserForm1.OptionButton2.Value = True Then MsgBox "OptionButton2 selected"
If UserForm1.OptionButton3.Value = True Then MsgBox "OptionButton3 selected"
 
T

Tom Ogilvy

Dim i as Long, j as Long
Dim obx as MSControls.OptionButton
for i = 1 to 3
if userform1.Controls("OptionButton" & i).Value then
j = i
exit for
end if
Next
set obx = userform1.Controls("OptionButton" & j)
 

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

Top