Help with OptionButtons on a Userform

R

Robert Crandal

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.
 
L

Lars-Åke Aspelin

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
 

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