ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with OptionButtons on a Userform (https://www.excelbanter.com/excel-programming/436741-help-optionbuttons-userform.html)

Robert Crandal

Help with OptionButtons on a Userform
 
I created my first Userform with a pair of OptionButtons.
So there two option buttons in my group and I need to
know how to set or check one of the option buttons
before or when the userform loads. How would I do this??

Btw, the option that gets set is going to depend on the
contents of cell A1. so if cell A1 contains integer value of
1, then i want OptionButton1 to be set. If A1 == 2, then
I want OptionButton2 to be set or checked.

thank you.



Lars-Åke Aspelin[_2_]

Help with OptionButtons on a Userform
 
On Fri, 27 Nov 2009 20:55:15 -0700, "Robert Crandal"
wrote:

I created my first Userform with a pair of OptionButtons.
So there two option buttons in my group and I need to
know how to set or check one of the option buttons
before or when the userform loads. How would I do this??

Btw, the option that gets set is going to depend on the
contents of cell A1. so if cell A1 contains integer value of
1, then i want OptionButton1 to be set. If A1 == 2, then
I want OptionButton2 to be set or checked.

thank you.



Try this macro

Private Sub UserForm_Activate()
If Worksheets("Sheet1").Cells(1, "A").Value = 1 Then
OptionButton1.Value = True
End If
If Worksheets("Sheet1").Cells(1, "A").Value = 2 Then
OptionButton2.Value = True
End If
End Sub

Hope this helps / Lars-Åke


All times are GMT +1. The time now is 10:38 AM.

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