LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default OPtion Button

The option button has two values, True and False. As Chip Pearson pointed
out, you should be able to access the option button value if the form is
hidden, but not if you unload it. Look up Unload in the VBA help file.
Access VBA help by pressing Alt + F11.

If your UserForm is UserForm1 and your OptionButton is OptionButton1, then
copy and paste the code below into your code module1.

Sub optBtnTest()
Load UserForm1
MsgBox UserForm1.OptionButton1.Value
Unload UserForm1
End Sub

Then run the macro.

You can also set the Control Source in the OptionButton properties to a cell
on a sheet that would show you the value of the OptionButton.

"art" wrote:

I don't understand what you are saying.
What I did was just hide the userform instead of unloading it, so the users
selection still stays. Is there another way to do that?

Thanks for responding.




"JLGWhiz" wrote:

UserForms are not part of a module, they exist at the project level. To
refer to a control on the UserForm, such as an option button, from outside
the UserForm code, you would have to include the UserForm in the reference:

myVar = UserForm1.OptionButton1.Value

"art" wrote:

Hello:

I made a userform with 2 option buttons, however When I reference the option
buttons in another vba module, it does not recognize it? It always diplays it
either as 0 value or false. How can reference the option button in another
code?

Please help.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set option button value using VBA Dan Thompson Excel Programming 2 July 11th 07 10:54 PM
need help on how to grey out one option button in one group box based on the selection of another option button in another group box George Excel Programming 12 March 11th 07 02:08 PM
keep source formatting is not an option in paste option button Tina Excel Discussion (Misc queries) 0 February 20th 06 09:58 PM
Option Button Help justaguyfromky Excel Discussion (Misc queries) 1 September 5th 05 09:48 PM
VBA - Option Button ajliaks[_19_] Excel Programming 1 May 5th 04 02:56 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"