ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use the Option box value in a module (https://www.excelbanter.com/excel-programming/340298-use-option-box-value-module.html)

Tempy

Use the Option box value in a module
 
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 ***

RonaldF

Use the Option box value in a module
 
'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"

--
Ronald Ferdinandus
http://www.ro-pay.nl


"Tempy" wrote:

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 ***


Tom Ogilvy

Use the Option box value in a module
 
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)

--
Regards,
Tom Ogilvy

"Tempy" wrote in message
...
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 ***





All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com